Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index ae242100253966303535caedb39c0ed59a949224..bc34cfafe08e08b3075ff8ae2b377c2393223255 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -1573,17 +1573,16 @@ void LCodeGen::DoMathFloorOfDiv(LMathFloorOfDiv* instr) { |
void LCodeGen::DoMulI(LMulI* instr) { |
- Register scratch = scratch0(); |
Register result = ToRegister(instr->result()); |
// Note that result may alias left. |
Register left = ToRegister(instr->left()); |
LOperand* right_op = instr->right(); |
- bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
bool bailout_on_minus_zero = |
instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero); |
+ bool overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
- if (right_op->IsConstantOperand() && !can_overflow) { |
+ if (right_op->IsConstantOperand()) { |
int32_t constant = ToInteger32(LConstantOperand::cast(right_op)); |
if (bailout_on_minus_zero && (constant < 0)) { |
@@ -1595,7 +1594,12 @@ void LCodeGen::DoMulI(LMulI* instr) { |
switch (constant) { |
case -1: |
- __ rsb(result, left, Operand::Zero()); |
+ if (overflow) { |
+ __ rsb(result, left, Operand::Zero(), SetCC); |
+ DeoptimizeIf(vs, instr->environment()); |
+ } else { |
+ __ rsb(result, left, Operand::Zero()); |
+ } |
break; |
case 0: |
if (bailout_on_minus_zero) { |
@@ -1616,23 +1620,21 @@ void LCodeGen::DoMulI(LMulI* instr) { |
int32_t mask = constant >> 31; |
uint32_t constant_abs = (constant + mask) ^ mask; |
- if (IsPowerOf2(constant_abs) || |
- IsPowerOf2(constant_abs - 1) || |
- IsPowerOf2(constant_abs + 1)) { |
- if (IsPowerOf2(constant_abs)) { |
- int32_t shift = WhichPowerOf2(constant_abs); |
- __ mov(result, Operand(left, LSL, shift)); |
- } else if (IsPowerOf2(constant_abs - 1)) { |
- int32_t shift = WhichPowerOf2(constant_abs - 1); |
- __ add(result, left, Operand(left, LSL, shift)); |
- } else if (IsPowerOf2(constant_abs + 1)) { |
- int32_t shift = WhichPowerOf2(constant_abs + 1); |
- __ rsb(result, left, Operand(left, LSL, shift)); |
- } |
- |
+ if (IsPowerOf2(constant_abs)) { |
+ int32_t shift = WhichPowerOf2(constant_abs); |
+ __ mov(result, Operand(left, LSL, shift)); |
+ // Correct the sign of the result is the constant is negative. |
+ if (constant < 0) __ rsb(result, result, Operand::Zero()); |
+ } else if (IsPowerOf2(constant_abs - 1)) { |
+ int32_t shift = WhichPowerOf2(constant_abs - 1); |
+ __ add(result, left, Operand(left, LSL, shift)); |
+ // Correct the sign of the result is the constant is negative. |
+ if (constant < 0) __ rsb(result, result, Operand::Zero()); |
+ } else if (IsPowerOf2(constant_abs + 1)) { |
+ int32_t shift = WhichPowerOf2(constant_abs + 1); |
+ __ rsb(result, left, Operand(left, LSL, shift)); |
// Correct the sign of the result is the constant is negative. |
if (constant < 0) __ rsb(result, result, Operand::Zero()); |
- |
} else { |
// Generate standard code. |
__ mov(ip, Operand(constant)); |
@@ -1641,12 +1643,11 @@ void LCodeGen::DoMulI(LMulI* instr) { |
} |
} else { |
- Register right = EmitLoadRegister(right_op, scratch); |
- if (bailout_on_minus_zero) { |
- __ orr(ToRegister(instr->temp()), left, right); |
- } |
+ ASSERT(right_op->IsRegister()); |
+ Register right = ToRegister(right_op); |
- if (can_overflow) { |
+ if (overflow) { |
+ Register scratch = scratch0(); |
// scratch:result = left * right. |
if (instr->hydrogen()->representation().IsSmi()) { |
__ SmiUntag(result, left); |
@@ -1666,12 +1667,12 @@ void LCodeGen::DoMulI(LMulI* instr) { |
} |
if (bailout_on_minus_zero) { |
- // Bail out if the result is supposed to be negative zero. |
Label done; |
+ __ teq(left, Operand(right)); |
+ __ b(pl, &done); |
+ // Bail out if the result is minus zero. |
__ cmp(result, Operand::Zero()); |
- __ b(ne, &done); |
- __ cmp(ToRegister(instr->temp()), Operand::Zero()); |
- DeoptimizeIf(mi, instr->environment()); |
+ DeoptimizeIf(eq, instr->environment()); |
__ bind(&done); |
} |
} |