Commit a1e6bee6 authored by sigurds's avatar sigurds Committed by Commit bot

[turbofan ] Simplify reference equal if both inputs are constants

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1532063002

Cr-Commit-Position: refs/heads/master@{#32950}
parent 01b8e7c7
...@@ -89,6 +89,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { ...@@ -89,6 +89,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value()));
break; break;
} }
case IrOpcode::kReferenceEqual:
return ReduceReferenceEqual(node);
default: default:
break; break;
} }
...@@ -96,6 +98,23 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { ...@@ -96,6 +98,23 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
} }
Reduction SimplifiedOperatorReducer::ReduceReferenceEqual(Node* node) {
DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode());
Node* const left = NodeProperties::GetValueInput(node, 0);
Node* const right = NodeProperties::GetValueInput(node, 1);
HeapObjectMatcher match_left(left);
HeapObjectMatcher match_right(right);
if (match_left.HasValue() && match_right.HasValue()) {
if (match_left.Value().is_identical_to(match_right.Value())) {
return Replace(jsgraph()->TrueConstant());
} else {
return Replace(jsgraph()->FalseConstant());
}
}
return NoChange();
}
Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op, Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
Node* a) { Node* a) {
DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op)); DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));
......
...@@ -25,6 +25,8 @@ class SimplifiedOperatorReducer final : public Reducer { ...@@ -25,6 +25,8 @@ class SimplifiedOperatorReducer final : public Reducer {
Reduction Reduce(Node* node) final; Reduction Reduce(Node* node) final;
private: private:
Reduction ReduceReferenceEqual(Node* node);
Reduction Change(Node* node, const Operator* op, Node* a); Reduction Change(Node* node, const Operator* op, Node* a);
Reduction ReplaceFloat64(double value); Reduction ReplaceFloat64(double value);
Reduction ReplaceInt32(int32_t value); Reduction ReplaceInt32(int32_t value);
......
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