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

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

Issue 647773004: [turbofan] Skip bounds checks for positive indices only. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 6 years, 2 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 | « test/mjsunit/asm/int32array-constant-key.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/simplified-operator-reducer-unittest.cc
diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc
index 694bdd87aa5b2c349a1f2fbc9429b3cb15d06300..3d342e385a151ef71bc58c3e9cebbe10f5264ce7 100644
--- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc
@@ -490,18 +490,46 @@ TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) {
Node* const base = Parameter(0);
Node* const effect = graph()->start();
Node* const control = graph()->start();
- TRACED_FOREACH(double, key, kFloat64Values) {
- TRACED_FOREACH(int32_t, length, kInt32Values) {
- if (key < length) {
- Reduction r = Reduce(graph()->NewNode(
- simplified()->LoadElement(access), base, NumberConstant(key),
- Int32Constant(length), effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsLoadElement(access_nocheck, base, IsNumberConstant(key),
- IsInt32Constant(length), effect, control));
- }
- }
+ {
+ Node* const key = NumberConstant(-42.0);
+ Node* const length = NumberConstant(100.0);
+ Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
+ base, key, length, effect, control));
+ ASSERT_FALSE(r.Changed());
+ }
+ {
+ Node* const key = NumberConstant(-0.0);
+ Node* const length = NumberConstant(1.0);
+ Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
+ base, key, length, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key,
+ length, effect, control));
+ }
+ {
+ Node* const key = Int32Constant(0);
+ Node* const length = Int32Constant(1);
+ Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
+ base, key, length, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key,
+ length, effect, control));
+ }
+ {
+ Node* const key = NumberConstant(42.2);
+ Node* const length = Int32Constant(128);
+ Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
+ base, key, length, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key,
+ length, effect, control));
+ }
+ {
+ Node* const key = NumberConstant(39.2);
+ Node* const length = NumberConstant(32.0);
+ Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access),
+ base, key, length, effect, control));
+ ASSERT_FALSE(r.Changed());
}
}
@@ -519,19 +547,54 @@ TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) {
Node* const value = Parameter(1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
- TRACED_FOREACH(int32_t, key, kInt32Values) {
- TRACED_FOREACH(double, length, kFloat64Values) {
- if (key < length) {
- Reduction r = Reduce(graph()->NewNode(
- simplified()->StoreElement(access), base, Int32Constant(key),
- NumberConstant(length), value, effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsStoreElement(access_nocheck, base, IsInt32Constant(key),
- IsNumberConstant(length), value, effect, control));
- }
- }
+ {
+ Node* const key = NumberConstant(-72.1);
+ Node* const length = NumberConstant(0.0);
+ Reduction r =
+ Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
+ length, value, effect, control));
+ ASSERT_FALSE(r.Changed());
+ }
+ {
+ Node* const key = NumberConstant(-0.0);
+ Node* const length = Int32Constant(999);
+ Reduction r =
+ Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
+ length, value, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(),
+ IsStoreElement(access_nocheck, base, key, length, value, effect,
+ control));
+ }
+ {
+ Node* const key = Int32Constant(0);
+ Node* const length = Int32Constant(1);
+ Reduction r =
+ Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
+ length, value, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(),
+ IsStoreElement(access_nocheck, base, key, length, value, effect,
+ control));
+ }
+ {
+ Node* const key = NumberConstant(42.2);
+ Node* const length = Int32Constant(128);
+ Reduction r =
+ Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
+ length, value, effect, control));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(),
+ IsStoreElement(access_nocheck, base, key, length, value, effect,
+ control));
+ }
+ {
+ Node* const key = NumberConstant(39.2);
+ Node* const length = NumberConstant(32.0);
+ Reduction r =
+ Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
+ length, value, effect, control));
+ ASSERT_FALSE(r.Changed());
}
}
« no previous file with comments | « test/mjsunit/asm/int32array-constant-key.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698