Commit 0b1b8c77 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Optimize ReferenceEqual based on input types.

We can constant-fold ReferenceEqual(a,b) to false, if the intersection
of the types of a and b is empty. This also repairs a regression in the
RestParameter performance test.

R=petermarshall@chromium.org
BUG=chromium:686668

Review-Url: https://codereview.chromium.org/2666543002
Cr-Commit-Position: refs/heads/master@{#42775}
parent db57a119
......@@ -92,6 +92,8 @@ Reduction TypedOptimization::Reduce(Node* node) {
return ReduceNumberToUint8Clamped(node);
case IrOpcode::kPhi:
return ReducePhi(node);
case IrOpcode::kReferenceEqual:
return ReduceReferenceEqual(node);
case IrOpcode::kSelect:
return ReduceSelect(node);
default:
......@@ -258,6 +260,18 @@ Reduction TypedOptimization::ReducePhi(Node* node) {
return NoChange();
}
Reduction TypedOptimization::ReduceReferenceEqual(Node* node) {
DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode());
Node* const lhs = NodeProperties::GetValueInput(node, 0);
Node* const rhs = NodeProperties::GetValueInput(node, 1);
Type* const lhs_type = NodeProperties::GetType(lhs);
Type* const rhs_type = NodeProperties::GetType(rhs);
if (!lhs_type->Maybe(rhs_type)) {
return Replace(jsgraph()->FalseConstant());
}
return NoChange();
}
Reduction TypedOptimization::ReduceSelect(Node* node) {
DCHECK_EQ(IrOpcode::kSelect, node->opcode());
Node* const condition = NodeProperties::GetValueInput(node, 0);
......
......@@ -50,6 +50,7 @@ class V8_EXPORT_PRIVATE TypedOptimization final
Reduction ReduceNumberRoundop(Node* node);
Reduction ReduceNumberToUint8Clamped(Node* node);
Reduction ReducePhi(Node* node);
Reduction ReduceReferenceEqual(Node* node);
Reduction ReduceSelect(Node* node);
CompilationDependencies* dependencies() const { return dependencies_; }
......
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