Commit dfc4b47f authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Strength reduce CheckTaggedSigned/Pointer with checked inputs.

Add strength reduction rules to optimize

 CheckTaggedSigned(CheckTaggedSigned(x)) -> CheckTaggedSigned(x)

and

 CheckTaggedPointer(CheckTaggedPointer(x)) -> CheckTaggedPointer(x)

where we do some cleanup optimizations after loop peeling and redundancy
elimination, which can generate these constructs.

BUG=v8:5267

Review-Url: https://codereview.chromium.org/2336093002
Cr-Commit-Position: refs/heads/master@{#39366}
parent a6399759
......@@ -148,6 +148,11 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
ReplaceWithValue(node, input);
return Replace(input);
}
NodeMatcher m(input);
if (m.IsCheckTaggedPointer()) {
ReplaceWithValue(node, input);
return Replace(input);
}
break;
}
case IrOpcode::kCheckTaggedSigned: {
......@@ -157,7 +162,10 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
return Replace(input);
}
NodeMatcher m(input);
if (m.IsConvertTaggedHoleToUndefined()) {
if (m.IsCheckTaggedSigned()) {
ReplaceWithValue(node, input);
return Replace(input);
} else if (m.IsConvertTaggedHoleToUndefined()) {
node->ReplaceInput(0, m.InputAt(0));
return Changed(node);
}
......
......@@ -378,6 +378,19 @@ TEST_F(SimplifiedOperatorReducerTest, CheckTaggedPointerWithHeapConstant) {
}
}
TEST_F(SimplifiedOperatorReducerTest,
CheckTaggedPointerWithCheckTaggedPointer) {
Node* param0 = Parameter(0);
Node* effect = graph()->start();
Node* control = graph()->start();
Node* value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(),
param0, effect, control);
Reduction reduction = Reduce(graph()->NewNode(
simplified()->CheckTaggedPointer(), value, effect, control));
ASSERT_TRUE(reduction.Changed());
EXPECT_EQ(value, reduction.replacement());
}
// -----------------------------------------------------------------------------
// CheckTaggedSigned
......@@ -404,6 +417,18 @@ TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithNumberConstant) {
EXPECT_EQ(value, reduction.replacement());
}
TEST_F(SimplifiedOperatorReducerTest, CheckTaggedSignedWithCheckTaggedSigned) {
Node* param0 = Parameter(0);
Node* effect = graph()->start();
Node* control = graph()->start();
Node* value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(),
param0, effect, control);
Reduction reduction = Reduce(graph()->NewNode(
simplified()->CheckTaggedSigned(), value, effect, control));
ASSERT_TRUE(reduction.Changed());
EXPECT_EQ(value, reduction.replacement());
}
// -----------------------------------------------------------------------------
// NumberAbs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment