Chromium Code Reviews| Index: src/compiler/simplified-lowering.cc |
| diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
| index 0cc53ed9b48072796dcc8a44757edd3412ca4660..9642988cf623c4ebfea79432f19afcf5bb83afcb 100644 |
| --- a/src/compiler/simplified-lowering.cc |
| +++ b/src/compiler/simplified-lowering.cc |
| @@ -1077,6 +1077,23 @@ class RepresentationSelector { |
| return jsgraph_->simplified(); |
| } |
| + void LowerToCheckedInt32MulWithOverflowOp(Node* node, Truncation truncation, |
|
Benedikt Meurer
2016/07/18 08:55:38
Nit: Just LowerToCheckedInt32Mul.
|
| + Type* input0_type, |
| + Type* input1_type) { |
| + // If one of the inputs is positive and/or truncation is being applied, |
| + // there is no need to return -0. |
| + CheckForMinusZeroMode mz_mode = |
| + truncation.TruncatesToWord32() || |
| + (input0_type->Is(Type::OrderedNumber()) && |
| + input0_type->Min() > 0) || |
| + (input1_type->Is(Type::OrderedNumber()) && |
| + input1_type->Min() > 0) |
| + ? CheckForMinusZeroMode::kDontCheckForMinusZero |
| + : CheckForMinusZeroMode::kCheckForMinusZero; |
| + |
| + NodeProperties::ChangeOp(node, simplified()->CheckedInt32Mul(mz_mode)); |
| + } |
| + |
| void ChangeToInt32OverflowOp(Node* node) { |
| NodeProperties::ChangeOp(node, Int32OverflowOp(node)); |
| } |
| @@ -1333,6 +1350,8 @@ class RepresentationSelector { |
| } |
| // Try to use type feedback. |
| BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
| + Type* input0_type = TypeOf(node->InputAt(0)); |
| + Type* input1_type = TypeOf(node->InputAt(1)); |
| // Handle the case when no int32 checks on inputs are necessary |
| // (but an overflow check is needed on the output). |
| @@ -1342,7 +1361,10 @@ class RepresentationSelector { |
| hint == BinaryOperationHints::kSigned32) { |
| VisitBinop(node, UseInfo::TruncatingWord32(), |
| MachineRepresentation::kWord32, Type::Signed32()); |
| - if (lower()) ChangeToInt32OverflowOp(node); |
| + if (lower()) { |
| + LowerToCheckedInt32MulWithOverflowOp(node, truncation, |
| + input0_type, input1_type); |
| + } |
| return; |
| } |
| } |
| @@ -1351,7 +1373,10 @@ class RepresentationSelector { |
| hint == BinaryOperationHints::kSigned32) { |
| VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), |
| MachineRepresentation::kWord32, Type::Signed32()); |
| - if (lower()) ChangeToInt32OverflowOp(node); |
| + if (lower()) { |
| + LowerToCheckedInt32MulWithOverflowOp(node, truncation, input0_type, |
| + input1_type); |
| + } |
| return; |
| } |