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 ac502416264bad2ffba984b2f68989d4d9af76d7..694bdd87aa5b2c349a1f2fbc9429b3cb15d06300 100644 |
--- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc |
+++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc |
@@ -6,6 +6,7 @@ |
#include "src/compiler/simplified-operator.h" |
#include "src/compiler/simplified-operator-reducer.h" |
#include "src/conversions.h" |
+#include "src/types.h" |
#include "test/unittests/compiler/graph-unittest.h" |
namespace v8 { |
@@ -476,6 +477,64 @@ TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) { |
} |
} |
+ |
+// ----------------------------------------------------------------------------- |
+// LoadElement |
+ |
+ |
+TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) { |
+ ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0, |
+ Type::Any(), kMachAnyTagged}; |
+ ElementAccess access_nocheck = access; |
+ access_nocheck.bounds_check = kNoBoundsCheck; |
+ 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)); |
+ } |
+ } |
+ } |
+} |
+ |
+ |
+// ----------------------------------------------------------------------------- |
+// StoreElement |
+ |
+ |
+TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { |
+ ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0, |
+ Type::Any(), kMachAnyTagged}; |
+ ElementAccess access_nocheck = access; |
+ access_nocheck.bounds_check = kNoBoundsCheck; |
+ Node* const base = Parameter(0); |
+ 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)); |
+ } |
+ } |
+ } |
+} |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |