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

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

Issue 598083007: [turbofan] Reduce shl with sar/shr and same shift amount to bit-and. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: file naming. Created 6 years, 3 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') | test/mjsunit/asm/int32array-unaligned.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/machine-operator-reducer-unittest.cc
diff --git a/src/compiler/machine-operator-reducer-unittest.cc b/src/compiler/machine-operator-reducer-unittest.cc
index f3073ab791bf2ce7d50614d22a8eb77124211247..5a76342f77e6a85e12b23cf6b3cbbfb6b195bc52 100644
--- a/src/compiler/machine-operator-reducer-unittest.cc
+++ b/src/compiler/machine-operator-reducer-unittest.cc
@@ -521,6 +521,49 @@ TEST_F(MachineOperatorReducerTest, Word32RorWithConstants) {
// -----------------------------------------------------------------------------
+// Word32Shl
+
+
+TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) {
+ Node* p0 = Parameter(0);
+ Node* node = graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(0));
+ Reduction r = Reduce(node);
+ ASSERT_TRUE(r.Changed());
+ EXPECT_EQ(p0, r.replacement());
+}
+
+
+TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Sar) {
+ Node* p0 = Parameter(0);
+ TRACED_FORRANGE(int32_t, x, 1, 31) {
+ Node* node = graph()->NewNode(
+ machine()->Word32Shl(),
+ graph()->NewNode(machine()->Word32Sar(), p0, Int32Constant(x)),
+ Int32Constant(x));
+ Reduction r = Reduce(node);
+ ASSERT_TRUE(r.Changed());
+ int32_t m = bit_cast<int32_t>(~((1U << x) - 1U));
+ EXPECT_THAT(r.replacement(), IsWord32And(p0, IsInt32Constant(m)));
+ }
+}
+
+
+TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Shr) {
+ Node* p0 = Parameter(0);
+ TRACED_FORRANGE(int32_t, x, 1, 31) {
+ Node* node = graph()->NewNode(
+ machine()->Word32Shl(),
+ graph()->NewNode(machine()->Word32Shr(), p0, Int32Constant(x)),
+ Int32Constant(x));
+ Reduction r = Reduce(node);
+ ASSERT_TRUE(r.Changed());
+ int32_t m = bit_cast<int32_t>(~((1U << x) - 1U));
+ EXPECT_THAT(r.replacement(), IsWord32And(p0, IsInt32Constant(m)));
+ }
+}
+
+
+// -----------------------------------------------------------------------------
// Int32AddWithOverflow
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | test/mjsunit/asm/int32array-unaligned.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698