Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index 6991363a3e297f0930a705eca9e72e66aa5dafd2..572a0aed2e501c32eba94fb02f69fb94059b30d1 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -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( |