aboutsummaryrefslogtreecommitdiff
path: root/vm/compiler/codegen/arm/CodegenDriver.c
diff options
context:
space:
mode:
authorBill Buzbee <buzbee@google.com>2010-02-11 14:35:57 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-02-11 14:35:57 -0800
commit9ebb8b820a845129775272f5058580122c3a89ce (patch)
treeac405e8cfb4a3910c73e81f11576e649ccc95a8a /vm/compiler/codegen/arm/CodegenDriver.c
parent2583639a965660e62e2a4552049619f84af37021 (diff)
parent78cb0e2c6e118c647915c3f8a72f1564cccb521a (diff)
Merge "Jit: Minor codegen tuning."
Diffstat (limited to 'vm/compiler/codegen/arm/CodegenDriver.c')
-rw-r--r--vm/compiler/codegen/arm/CodegenDriver.c29
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;