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 41e69f0a833532647e0b024e5e9467fb5ce180a7..3037ff7307871341a73c60d43c1223ca374d1a39 100644 |
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc |
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc |
@@ -501,6 +501,30 @@ TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithConstant) { |
// Word32And |
+TEST_F(MachineOperatorReducerTest, Word32AndWithWord32ShlWithConstant) { |
+ Node* const p0 = Parameter(0); |
+ |
+ TRACED_FORRANGE(int32_t, l, 1, 31) { |
+ TRACED_FORRANGE(int32_t, k, 1, l) { |
+ // (x << L) & (-1 << K) => x << L |
+ Reduction const r1 = Reduce(graph()->NewNode( |
+ machine()->Word32And(), |
+ graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(l)), |
+ Int32Constant(-1 << k))); |
+ ASSERT_TRUE(r1.Changed()); |
+ EXPECT_THAT(r1.replacement(), IsWord32Shl(p0, IsInt32Constant(l))); |
+ |
+ // (-1 << K) & (x << L) => x << L |
+ Reduction const r2 = Reduce(graph()->NewNode( |
+ machine()->Word32And(), Int32Constant(-1 << k), |
+ graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(l)))); |
+ ASSERT_TRUE(r2.Changed()); |
+ EXPECT_THAT(r2.replacement(), IsWord32Shl(p0, IsInt32Constant(l))); |
+ } |
+ } |
+} |
+ |
+ |
TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) { |
Node* const p0 = Parameter(0); |