diff options
| author | Bill Buzbee <buzbee@google.com> | 2010-02-11 14:04:53 -0800 |
|---|---|---|
| committer | Bill Buzbee <buzbee@google.com> | 2010-02-11 14:19:35 -0800 |
| commit | 78cb0e2c6e118c647915c3f8a72f1564cccb521a (patch) | |
| tree | 23461f492dfc71a228b7173d4250049f3e19bd90 /vm/compiler/codegen/arm/CodegenDriver.c | |
| parent | 1357e94efecd485bda933270a9181035f6a39e09 (diff) | |
Jit: Minor codegen tuning.
Diffstat (limited to 'vm/compiler/codegen/arm/CodegenDriver.c')
| -rw-r--r-- | vm/compiler/codegen/arm/CodegenDriver.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/vm/compiler/codegen/arm/CodegenDriver.c b/vm/compiler/codegen/arm/CodegenDriver.c index 5b4e83f46..99d392dd0 100644 --- a/vm/compiler/codegen/arm/CodegenDriver.c +++ b/vm/compiler/codegen/arm/CodegenDriver.c @@ -1835,6 +1835,22 @@ static bool handleFmt21t(CompilationUnit *cUnit, MIR *mir, BasicBlock *bb, return false; } +/* Positive power of 2? Return shiftCount if so, -1 if not */ +static int mulToShift(int val) { + int shiftCount; + if (val > 0 && ((val & (val - 1)) == 0)) { + shiftCount = 0; + val = ~val & (val - 1); + while (val) { + shiftCount++; + val >>= 1; + } + } else { + shiftCount = -1; + } + return shiftCount; +} + static bool handleFmt22b_Fmt22s(CompilationUnit *cUnit, MIR *mir) { OpCode dalvikOpCode = mir->dalvikInsn.opCode; @@ -1870,9 +1886,18 @@ static bool handleFmt22b_Fmt22s(CompilationUnit *cUnit, MIR *mir) op = kOpAdd; break; case OP_MUL_INT_LIT8: - case OP_MUL_INT_LIT16: - op = kOpMul; + case OP_MUL_INT_LIT16: { + // TUNING: General shift & add for small constants + int shiftCount = mulToShift(lit); + if (shiftCount >= 0) { + op = kOpLsl; + lit = shiftCount; + shiftOp = true; + } else { + op = kOpMul; + } break; + } case OP_AND_INT_LIT8: case OP_AND_INT_LIT16: op = kOpAnd; |
