Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: src/compiler/machine-operator-reducer.cc

Issue 2230213002: Revert of [turbofan] Reduces x << y ^ x >>> (32 - y) to x ror (32 - y). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index c06f06e68c8c8a0bf84b631d5b628ba4456aabdc..4aeeeeacfcf2670d7b19059eeceeaa40dae2616f 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -150,8 +150,21 @@
return ReduceWord32And(node);
case IrOpcode::kWord32Or:
return ReduceWord32Or(node);
- case IrOpcode::kWord32Xor:
- return ReduceWord32Xor(node);
+ case IrOpcode::kWord32Xor: {
+ Int32BinopMatcher m(node);
+ if (m.right().Is(0)) return Replace(m.left().node()); // x ^ 0 => x
+ if (m.IsFoldable()) { // K ^ K => K
+ return ReplaceInt32(m.left().Value() ^ m.right().Value());
+ }
+ if (m.LeftEqualsRight()) return ReplaceInt32(0); // x ^ x => 0
+ if (m.left().IsWord32Xor() && m.right().Is(-1)) {
+ Int32BinopMatcher mleft(m.left().node());
+ if (mleft.right().Is(-1)) { // (x ^ -1) ^ -1 => x
+ return Replace(mleft.left().node());
+ }
+ }
+ break;
+ }
case IrOpcode::kWord32Shl:
return ReduceWord32Shl(node);
case IrOpcode::kWord32Shr:
@@ -1093,17 +1106,22 @@
return NoChange();
}
-Reduction MachineOperatorReducer::TryMatchWord32Ror(Node* node) {
- DCHECK(IrOpcode::kWord32Or == node->opcode() ||
- IrOpcode::kWord32Xor == node->opcode());
+
+Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) {
+ DCHECK_EQ(IrOpcode::kWord32Or, node->opcode());
Int32BinopMatcher m(node);
+ if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x
+ if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1
+ if (m.IsFoldable()) { // K | K => K
+ return ReplaceInt32(m.left().Value() | m.right().Value());
+ }
+ if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x
+
Node* shl = nullptr;
Node* shr = nullptr;
- // Recognize rotation, we are matching:
+ // Recognize rotation, we are matching either:
// * x << y | x >>> (32 - y) => x ror (32 - y), i.e x rol y
// * x << (32 - y) | x >>> y => x ror y
- // * x << y ^ x >>> (32 - y) => x ror (32 - y), i.e. x rol y
- // * x << (32 - y) ^ x >>> y => x ror y
// as well as their commuted form.
if (m.left().IsWord32Shl() && m.right().IsWord32Shr()) {
shl = m.left().node();
@@ -1145,36 +1163,6 @@
return Changed(node);
}
-Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) {
- DCHECK_EQ(IrOpcode::kWord32Or, node->opcode());
- Int32BinopMatcher m(node);
- if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x
- if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1
- if (m.IsFoldable()) { // K | K => K
- return ReplaceInt32(m.left().Value() | m.right().Value());
- }
- if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x
-
- return TryMatchWord32Ror(node);
-}
-
-Reduction MachineOperatorReducer::ReduceWord32Xor(Node* node) {
- DCHECK_EQ(IrOpcode::kWord32Xor, node->opcode());
- Int32BinopMatcher m(node);
- if (m.right().Is(0)) return Replace(m.left().node()); // x ^ 0 => x
- if (m.IsFoldable()) { // K ^ K => K
- return ReplaceInt32(m.left().Value() ^ m.right().Value());
- }
- if (m.LeftEqualsRight()) return ReplaceInt32(0); // x ^ x => 0
- if (m.left().IsWord32Xor() && m.right().Is(-1)) {
- Int32BinopMatcher mleft(m.left().node());
- if (mleft.right().Is(-1)) { // (x ^ -1) ^ -1 => x
- return Replace(mleft.left().node());
- }
- }
-
- return TryMatchWord32Ror(node);
-}
Reduction MachineOperatorReducer::ReduceFloat64InsertLowWord32(Node* node) {
DCHECK_EQ(IrOpcode::kFloat64InsertLowWord32, node->opcode());
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698