diff options
| author | 2012-04-11 16:33:36 -0700 | |
|---|---|---|
| committer | 2012-04-11 16:33:36 -0700 | |
| commit | f3aac973bb944885a1a4779ba04a97faa88b7ed0 (patch) | |
| tree | fea6d65da9770addbff35ae610ee6c1d0c397644 /src/compiler/codegen/GenCommon.cc | |
| parent | 933abf8ce64e522b1c45b191b796bf2208a760d9 (diff) | |
Special case division by small constants
Do the standard reciprocal multiply trick for small division
by small constants.
Change-Id: Iad1060ccdc6ffeb7b47d45c29ba741683ad01ab9
Diffstat (limited to 'src/compiler/codegen/GenCommon.cc')
| -rw-r--r-- | src/compiler/codegen/GenCommon.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/codegen/GenCommon.cc b/src/compiler/codegen/GenCommon.cc index 066c37cacd..71fd33cc56 100644 --- a/src/compiler/codegen/GenCommon.cc +++ b/src/compiler/codegen/GenCommon.cc @@ -27,6 +27,8 @@ void genInvoke(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir, InvokeType type, bool isRange); #if defined(TARGET_ARM) LIR* opIT(CompilationUnit* cUnit, ArmConditionCode cond, const char* guide); +bool smallLiteralDivide(CompilationUnit* cUnit, Instruction::Code dalvikOpcode, + RegLocation rlSrc, RegLocation rlDest, int lit); #endif void callRuntimeHelperImm(CompilationUnit* cUnit, int helperOffset, int arg0) { @@ -1915,9 +1917,19 @@ int lowestSetBit(unsigned int x) { bool handleEasyDivide(CompilationUnit* cUnit, Instruction::Code dalvikOpcode, RegLocation rlSrc, RegLocation rlDest, int lit) { +#if defined(TARGET_ARM) + // No divide instruction for Arm, so check for more special cases + if (lit < 2) { + return false; + } + if (!isPowerOfTwo(lit)) { + return smallLiteralDivide(cUnit, dalvikOpcode, rlSrc, rlDest, lit); + } +#else if (lit < 2 || !isPowerOfTwo(lit)) { return false; } +#endif int k = lowestSetBit(lit); if (k >= 30) { // Avoid special cases. |