Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: src/arm/lithium-codegen-arm.cc

Issue 6665006: Reduce strength of ModI for power-of-2 divisor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: port to arm and x64 Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698