Commit 53d92c1c authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Lower to NumberAdd / NumberSubtract if type feedback is Number.

If JSAdd or JSSubtract has number feedback, there's no benefit to use
the speculative versions of NumberAdd and/or NumberSubtract. Relying on
the existing operators gives us some nice truncations instead, so let's
stick to that for now.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2063073004
Cr-Commit-Position: refs/heads/master@{#36987}
parent ae23436c
......@@ -404,6 +404,14 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
JSBinopReduction r(this, node);
BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback();
if (feedback == BinaryOperationHints::kNumberOrUndefined &&
r.BothInputsAre(Type::PlainPrimitive()) &&
r.NeitherInputCanBe(Type::StringOrReceiver())) {
// JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y))
Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
r.ConvertInputsToNumber(frame_state);
return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
}
if (feedback != BinaryOperationHints::kAny) {
// Lower to the optimistic number binop.
return r.ChangeToSpeculativeOperator(
......@@ -462,6 +470,15 @@ Reduction JSTypedLowering::ReduceJSSubtract(Node* node) {
if (flags() & kDisableBinaryOpReduction) return NoChange();
JSBinopReduction r(this, node);
BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback();
if (feedback == BinaryOperationHints::kNumberOrUndefined &&
r.BothInputsAre(Type::PlainPrimitive())) {
// JSSubtract(x:plain-primitive, y:plain-primitive)
// => NumberSubtract(ToNumber(x), ToNumber(y))
Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
r.ConvertInputsToNumber(frame_state);
return r.ChangeToPureOperator(simplified()->NumberSubtract(),
Type::Number());
}
if (feedback != BinaryOperationHints::kAny) {
// Lower to the optimistic number binop.
return r.ChangeToSpeculativeOperator(
......
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