Index: test/unittests/compiler/machine-operator-reducer-unittest.cc |
diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc |
index d8640163b3e9d9d6e977f0aacc4d9177882cc36c..6e1b12f79e0449c1fb974855e2edff1a9c6100be 100644 |
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc |
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc |
@@ -526,6 +526,25 @@ TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) { |
} |
+TEST_F(MachineOperatorReducerTest, Word32AndWithInt32AddAndConstant) { |
+ Node* const p0 = Parameter(0); |
+ |
+ TRACED_FOREACH(int32_t, k, kInt32Values) { |
+ TRACED_FORRANGE(int32_t, l, 1, 31) { |
+ // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L) |
+ Reduction const r = Reduce(graph()->NewNode( |
+ machine()->Word32And(), |
+ graph()->NewNode(machine()->Int32Add(), p0, Int32Constant(k << l)), |
+ Int32Constant(-1 << l))); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsInt32Add(IsWord32And(p0, IsInt32Constant(-1 << l)), |
+ IsInt32Constant(k << l))); |
+ } |
+ } |
+} |
+ |
+ |
// ----------------------------------------------------------------------------- |
// Word32Xor |