[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}
This commit is contained in:
sigurds 2015-12-17 06:47:06 -08:00 committed by Commit bot
parent 01b8e7c7f6
commit a1e6bee6ec
2 changed files with 21 additions and 0 deletions

View File

@ -89,6 +89,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value()));
break;
}
case IrOpcode::kReferenceEqual:
return ReduceReferenceEqual(node);
default:
break;
}
@ -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,
Node* a) {
DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));

View File

@ -25,6 +25,8 @@ class SimplifiedOperatorReducer final : public Reducer {
Reduction Reduce(Node* node) final;
private:
Reduction ReduceReferenceEqual(Node* node);
Reduction Change(Node* node, const Operator* op, Node* a);
Reduction ReplaceFloat64(double value);
Reduction ReplaceInt32(int32_t value);