Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 8dd35b6b8394251c79842b7a56e4097d82b5cd5b..e188f8136689a5737173ebb573617ceda287e727 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -796,6 +796,31 @@ void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
void LCodeGen::DoModI(LModI* instr) { |
+ if (HMod::cast(instr->hydrogen())->HasPowerOf2Divisor()) { |
Kevin Millikin (Chromium)
2011/03/14 14:35:07
The HMod::cast should not be necessary here (and j
|
+ Register dividend = ToRegister(instr->InputAt(0)); |
+ |
+ int32_t divisor = |
+ HConstant::cast( |
+ HMod::cast(instr->hydrogen())->right())->Integer32Value(); |
+ |
+ if (divisor < 0) divisor = -divisor; |
+ |
+ Label positive_dividend, done; |
+ __ tst(dividend, Operand(dividend)); |
+ __ b(pl, &positive_dividend); |
+ __ rsb(dividend, dividend, Operand(0)); |
+ __ and_(dividend, dividend, Operand(divisor - 1)); |
+ __ rsb(dividend, dividend, Operand(0), SetCC); |
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
+ __ b(ne, &done); |
+ DeoptimizeIf(al, instr->environment()); |
+ } |
+ __ bind(&positive_dividend); |
+ __ and_(dividend, dividend, Operand(divisor - 1)); |
+ __ bind(&done); |
+ return; |
+ } |
+ |
class DeferredModI: public LDeferredCode { |
public: |
DeferredModI(LCodeGen* codegen, LModI* instr) |
@@ -856,6 +881,7 @@ void LCodeGen::DoModI(LModI* instr) { |
__ JumpIfNotPowerOfTwoOrZero(right, scratch, &call_stub); |
// Perform modulo operation (scratch contains right - 1). |
__ and_(result, scratch, Operand(left)); |
+ __ b(&done); |
__ bind(&call_stub); |
// Call the stub. The numbers in r0 and r1 have |