Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index a8536a1841f379a5078e5fc79716f16e9564024f..a28d6c6f4086c6b6eef3f1b2fc9c34e9bfc7a0f8 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -1139,22 +1139,28 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) { |
} |
// If the divisor is negative, we have to negate and handle edge cases. |
- Label not_kmin_int, done; |
__ negl(dividend); |
if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
DeoptimizeIf(zero, instr->environment()); |
} |
- if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
- // Note that we could emit branch-free code, but that would need one more |
- // register. |
- __ j(no_overflow, ¬_kmin_int, Label::kNear); |
- if (divisor == -1) { |
- DeoptimizeIf(no_condition, instr->environment()); |
- } else { |
- __ movl(dividend, Immediate(kMinInt / divisor)); |
- __ jmp(&done, Label::kNear); |
- } |
+ |
+ // If the negation could not overflow, simply shifting is OK. |
+ if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
+ __ sarl(dividend, Immediate(shift)); |
+ return; |
} |
+ |
+ // Note that we could emit branch-free code, but that would need one more |
+ // register. |
+ if (divisor == -1) { |
+ DeoptimizeIf(overflow, instr->environment()); |
+ return; |
+ } |
+ |
+ Label not_kmin_int, done; |
+ __ j(no_overflow, ¬_kmin_int, Label::kNear); |
+ __ movl(dividend, Immediate(kMinInt / divisor)); |
+ __ jmp(&done, Label::kNear); |
__ bind(¬_kmin_int); |
__ sarl(dividend, Immediate(shift)); |
__ bind(&done); |