Index: src/crankshaft/x87/lithium-x87.cc |
diff --git a/src/crankshaft/x87/lithium-x87.cc b/src/crankshaft/x87/lithium-x87.cc |
index b422e1235b49994728a575736f3bb907b809d476..a2eb343e465ddedc9183d29493159ff75894adba 100644 |
--- a/src/crankshaft/x87/lithium-x87.cc |
+++ b/src/crankshaft/x87/lithium-x87.cc |
@@ -1534,14 +1534,22 @@ LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
DCHECK(instr->left()->representation().Equals(instr->representation())); |
DCHECK(instr->right()->representation().Equals(instr->representation())); |
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
- LOperand* right = UseOrConstant(instr->BetterRightOperand()); |
+ HValue* h_right = instr->BetterRightOperand(); |
+ LOperand* right = UseOrConstant(h_right); |
LOperand* temp = NULL; |
if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
temp = TempRegister(); |
} |
LMulI* mul = new(zone()) LMulI(left, right, temp); |
- if (instr->CheckFlag(HValue::kCanOverflow) || |
- instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
+ int constant_value = |
+ h_right->IsConstant() ? HConstant::cast(h_right)->Integer32Value() : 0; |
+ // |needs_environment| must mirror the cases where LCodeGen::DoMulI calls |
+ // |DeoptimizeIf|. |
+ bool needs_environment = |
+ instr->CheckFlag(HValue::kCanOverflow) || |
+ (instr->CheckFlag(HValue::kBailoutOnMinusZero) && |
+ (!right->IsConstantOperand() || constant_value <= 0)); |
+ if (needs_environment) { |
AssignEnvironment(mul); |
} |
return DefineSameAsFirst(mul); |