Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index 0f6f38cb0f38f120163956faf008373631c0b6d1..2f0497f50393415217b011aa4c71a9a1a3b66f8a 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -388,10 +388,21 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) { |
} |
+Reduction JSTypedLowering::ReduceJSModulus(Node* node) { |
+ JSBinopReduction r(this, node); |
+ if (r.BothInputsAre(Type::Number())) { |
+ // JSModulus(x:number, x:number) => NumberModulus(x, y) |
+ return r.ChangeToPureOperator(simplified()->NumberModulus(), |
+ Type::Number()); |
+ } |
+ return NoChange(); |
+} |
+ |
+ |
Reduction JSTypedLowering::ReduceNumberBinop(Node* node, |
const Operator* numberOp) { |
JSBinopReduction r(this, node); |
- if (r.IsStrong()) { |
+ if (r.IsStrong() || numberOp == simplified()->NumberModulus()) { |
if (r.BothInputsAre(Type::Number())) { |
return r.ChangeToPureOperator(numberOp, Type::Number()); |
} |
@@ -1469,7 +1480,7 @@ Reduction JSTypedLowering::Reduce(Node* node) { |
case IrOpcode::kJSDivide: |
return ReduceNumberBinop(node, simplified()->NumberDivide()); |
case IrOpcode::kJSModulus: |
- return ReduceNumberBinop(node, simplified()->NumberModulus()); |
+ return ReduceJSModulus(node); |
case IrOpcode::kJSUnaryNot: |
return ReduceJSUnaryNot(node); |
case IrOpcode::kJSToBoolean: |