Index: src/arm/lithium-arm.cc |
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc |
index c5b0c1dfae9c209507cfba7059a532f67cbd86a1..fb7c103a908cdcaaca468dddf48ee0720e4a9ffa 100644 |
--- a/src/arm/lithium-arm.cc |
+++ b/src/arm/lithium-arm.cc |
@@ -1350,10 +1350,21 @@ LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
// when we provide a native implementation. |
ASSERT(instr->left()->representation().IsInteger32()); |
ASSERT(instr->right()->representation().IsInteger32()); |
- LOperand* value = UseFixed(instr->left(), r0); |
- LOperand* divisor = UseFixed(instr->right(), r1); |
- LInstruction* result = DefineFixed(new LModI(value, divisor), r0); |
- result = AssignEnvironment(AssignPointerMap(result)); |
+ |
+ LInstruction* result; |
+ if (instr->HasPowerOf2Divisor()) { |
+ ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
+ LOperand* value = UseRegisterAtStart(instr->left()); |
+ LModI* mod = new LModI(value, UseOrConstant(instr->right())); |
+ result = DefineSameAsFirst(mod); |
+ result = AssignEnvironment(result); |
+ } else { |
+ LOperand* value = UseFixed(instr->left(), r0); |
+ LOperand* divisor = UseFixed(instr->right(), r1); |
+ result = DefineFixed(new LModI(value, divisor), r0); |
+ result = AssignEnvironment(AssignPointerMap(result)); |
+ } |
+ |
return result; |
} else if (instr->representation().IsTagged()) { |
return DoArithmeticT(Token::MOD, instr); |