| Index: test/unittests/compiler/load-elimination-unittest.cc
|
| diff --git a/test/unittests/compiler/load-elimination-unittest.cc b/test/unittests/compiler/load-elimination-unittest.cc
|
| index 1c5a8375015baae5d51f65067dfbd18a6c636e42..2306f72b4c32f1482a43f1373e11c678f43f943e 100644
|
| --- a/test/unittests/compiler/load-elimination-unittest.cc
|
| +++ b/test/unittests/compiler/load-elimination-unittest.cc
|
| @@ -359,6 +359,64 @@ TEST_F(LoadEliminationTest, LoadFieldOnTrueBranchOfDiamond) {
|
| EXPECT_EQ(load, r.replacement());
|
| }
|
|
|
| +TEST_F(LoadEliminationTest, LoadFieldWithTypeMismatch) {
|
| + Node* object = Parameter(Type::Any(), 0);
|
| + Node* value = Parameter(Type::Signed32(), 1);
|
| + Node* effect = graph()->start();
|
| + Node* control = graph()->start();
|
| + FieldAccess const access = {kTaggedBase,
|
| + kPointerSize,
|
| + MaybeHandle<Name>(),
|
| + Type::Unsigned31(),
|
| + MachineType::AnyTagged(),
|
| + kNoWriteBarrier};
|
| +
|
| + StrictMock<MockAdvancedReducerEditor> editor;
|
| + LoadElimination load_elimination(&editor, jsgraph(), zone());
|
| +
|
| + load_elimination.Reduce(graph()->start());
|
| +
|
| + Node* store = effect = graph()->NewNode(simplified()->StoreField(access),
|
| + object, value, effect, control);
|
| + load_elimination.Reduce(effect);
|
| +
|
| + Node* load = graph()->NewNode(simplified()->LoadField(access), object, effect,
|
| + control);
|
| + EXPECT_CALL(editor,
|
| + ReplaceWithValue(load, IsTypeGuard(value, control), store, _));
|
| + Reduction r = load_elimination.Reduce(load);
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(), IsTypeGuard(value, control));
|
| +}
|
| +
|
| +TEST_F(LoadEliminationTest, LoadElementWithTypeMismatch) {
|
| + Node* object = Parameter(Type::Any(), 0);
|
| + Node* index = Parameter(Type::UnsignedSmall(), 1);
|
| + Node* value = Parameter(Type::Signed32(), 2);
|
| + Node* effect = graph()->start();
|
| + Node* control = graph()->start();
|
| + ElementAccess const access = {kTaggedBase, kPointerSize, Type::Unsigned31(),
|
| + MachineType::AnyTagged(), kNoWriteBarrier};
|
| +
|
| + StrictMock<MockAdvancedReducerEditor> editor;
|
| + LoadElimination load_elimination(&editor, jsgraph(), zone());
|
| +
|
| + load_elimination.Reduce(graph()->start());
|
| +
|
| + Node* store = effect =
|
| + graph()->NewNode(simplified()->StoreElement(access), object, index, value,
|
| + effect, control);
|
| + load_elimination.Reduce(effect);
|
| +
|
| + Node* load = graph()->NewNode(simplified()->LoadElement(access), object,
|
| + index, effect, control);
|
| + EXPECT_CALL(editor,
|
| + ReplaceWithValue(load, IsTypeGuard(value, control), store, _));
|
| + Reduction r = load_elimination.Reduce(load);
|
| + ASSERT_TRUE(r.Changed());
|
| + EXPECT_THAT(r.replacement(), IsTypeGuard(value, control));
|
| +}
|
| +
|
| } // namespace compiler
|
| } // namespace internal
|
| } // namespace v8
|
|
|