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

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

Issue 763963002: [turbofan] Add checked load/store operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reapply fix. Created 6 years 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 | « test/unittests/compiler/js-typed-lowering-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | 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 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) {
« no previous file with comments | « test/unittests/compiler/js-typed-lowering-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698