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

Unified Diff: test/unittests/compiler/machine-operator-reducer-unittest.cc

Issue 847113002: [turbofan] Reduce Word32And masking with shifted inputs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698