Index: src/ia32/lithium-codegen-ia32.cc |
=================================================================== |
--- src/ia32/lithium-codegen-ia32.cc (revision 13283) |
+++ src/ia32/lithium-codegen-ia32.cc (working copy) |
@@ -1212,7 +1212,7 @@ |
void LCodeGen::DoDivI(LDivI* instr) { |
- if (instr->hydrogen()->HasPowerOf2Divisor()) { |
+ if (!instr->is_flooring() && instr->hydrogen()->HasPowerOf2Divisor()) { |
Register dividend = ToRegister(instr->left()); |
int32_t divisor = |
HConstant::cast(instr->hydrogen()->right())->Integer32Value(); |
@@ -1259,13 +1259,13 @@ |
// Check for x / 0. |
Register right_reg = ToRegister(right); |
- if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
+ if (instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) { |
__ test(right_reg, ToOperand(right)); |
DeoptimizeIf(zero, instr->environment()); |
} |
// Check for (0 / -x) that will produce negative zero. |
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
+ if (instr->hydrogen_value()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
Label left_not_zero; |
__ test(left_reg, Operand(left_reg)); |
__ j(not_zero, &left_not_zero, Label::kNear); |
@@ -1275,7 +1275,7 @@ |
} |
// Check for (kMinInt / -1). |
- if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { |
+ if (instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)) { |
Label left_not_min_int; |
__ cmp(left_reg, kMinInt); |
__ j(not_zero, &left_not_min_int, Label::kNear); |
@@ -1288,9 +1288,19 @@ |
__ cdq(); |
__ idiv(right_reg); |
- // Deoptimize if remainder is not 0. |
- __ test(edx, Operand(edx)); |
- DeoptimizeIf(not_zero, instr->environment()); |
+ if (!instr->is_flooring()) { |
+ // Deoptimize if remainder is not 0. |
+ __ test(edx, Operand(edx)); |
+ DeoptimizeIf(not_zero, instr->environment()); |
+ } else { |
+ Label done; |
+ __ test(edx, edx); |
+ __ j(zero, &done, Label::kNear); |
+ __ xor_(edx, right_reg); |
+ __ sar(edx, 31); |
+ __ add(eax, edx); |
+ __ bind(&done); |
+ } |
} |