Index: src/crankshaft/x64/lithium-x64.cc |
diff --git a/src/crankshaft/x64/lithium-x64.cc b/src/crankshaft/x64/lithium-x64.cc |
index 3c932a24abde50fc7fc6115e5dec6cb891b6270b..14f03321fae32dd7dc93faeefa276d4de1459c1e 100644 |
--- a/src/crankshaft/x64/lithium-x64.cc |
+++ b/src/crankshaft/x64/lithium-x64.cc |
@@ -1511,10 +1511,18 @@ 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); |
LMulI* mul = new(zone()) LMulI(left, right); |
- 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); |