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 9377f1fa511546cee7ed702c3db273904e1ee139..5f9f1134a36c50e436bb43e17f52731268b53823 100644 |
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc |
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc |
@@ -512,7 +512,9 @@ TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) { |
graph()->NewNode(machine()->Word32And(), p0, Int32Constant(k)), |
Int32Constant(l))); |
ASSERT_TRUE(r1.Changed()); |
- EXPECT_THAT(r1.replacement(), IsWord32And(p0, IsInt32Constant(k & l))); |
+ EXPECT_THAT(r1.replacement(), |
+ (k & l) ? IsWord32And(p0, IsInt32Constant(k & l)) |
+ : IsInt32Constant(0)); |
// (K & x) & L => x & (K & L) |
Reduction const r2 = Reduce(graph()->NewNode( |
@@ -520,7 +522,9 @@ TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) { |
graph()->NewNode(machine()->Word32And(), Int32Constant(k), p0), |
Int32Constant(l))); |
ASSERT_TRUE(r2.Changed()); |
- EXPECT_THAT(r2.replacement(), IsWord32And(p0, IsInt32Constant(k & l))); |
+ EXPECT_THAT(r2.replacement(), |
+ (k & l) ? IsWord32And(p0, IsInt32Constant(k & l)) |
+ : IsInt32Constant(0)); |
} |
} |
} |
@@ -740,6 +744,28 @@ TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Sar) { |
} |
+TEST_F(MachineOperatorReducerTest, |
+ Word32ShlWithWord32SarAndInt32AddAndConstant) { |
+ Node* const p0 = Parameter(0); |
+ TRACED_FOREACH(int32_t, k, kInt32Values) { |
+ TRACED_FORRANGE(int32_t, l, 1, 31) { |
+ // (x + (K << L)) >> L << L => (x & (-1 << L)) + (K << L) |
+ Reduction const r = Reduce(graph()->NewNode( |
+ machine()->Word32Shl(), |
+ graph()->NewNode(machine()->Word32Sar(), |
+ graph()->NewNode(machine()->Int32Add(), p0, |
+ Int32Constant(k << l)), |
+ Int32Constant(l)), |
+ Int32Constant(l))); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsInt32Add(IsWord32And(p0, IsInt32Constant(-1 << l)), |
+ IsInt32Constant(k << l))); |
+ } |
+ } |
+} |
+ |
+ |
TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Shr) { |
Node* p0 = Parameter(0); |
TRACED_FORRANGE(int32_t, x, 1, 31) { |