diff options
| author | Ben Cheng <bccheng@android.com> | 2010-03-25 16:16:02 -0700 |
|---|---|---|
| committer | Ben Cheng <bccheng@android.com> | 2010-03-25 16:18:34 -0700 |
| commit | 63868feb2cc6a1fb1c76d7b54296ef4869f632be (patch) | |
| tree | 076722ea336594185af2b507e17053519b39e92e /vm/compiler/codegen/arm/LocalOptimizations.c | |
| parent | f2f7880a40aed1c8d9c27db49226e47396556aac (diff) | |
Use correct resource flags for Dalvik ld/st instructions to enable code motion.
Change-Id: I9b371af4150b6245c0ff59eea63d83406edbbcee
Diffstat (limited to 'vm/compiler/codegen/arm/LocalOptimizations.c')
| -rw-r--r-- | vm/compiler/codegen/arm/LocalOptimizations.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/vm/compiler/codegen/arm/LocalOptimizations.c b/vm/compiler/codegen/arm/LocalOptimizations.c index fbeceef4d..85dfa8ef1 100644 --- a/vm/compiler/codegen/arm/LocalOptimizations.c +++ b/vm/compiler/codegen/arm/LocalOptimizations.c @@ -150,8 +150,9 @@ static void applyLoadStoreElimination(CompilationUnit *cUnit, *newStoreLIR = *thisLIR; newStoreLIR->age = cUnit->optRound; /* - * Insertion is guaranteed to succeed since checkLIR - * is never the first LIR on the list + * Stop point found - insert *before* the checkLIR + * since the instruction list is scanned in the + * top-down order. */ dvmCompilerInsertLIRBefore((LIR *) checkLIR, (LIR *) newStoreLIR); @@ -211,9 +212,9 @@ static void applyLoadHoisting(CompilationUnit *cUnit, int nativeRegId = thisLIR->operands[0]; ArmLIR *checkLIR; int hoistDistance = 0; - u8 stopUseMask = (ENCODE_REG_PC | thisLIR->useMask) & - ~ENCODE_FRAME_REF; - u8 stopDefMask = thisLIR->defMask & ~ENCODE_FRAME_REF; + u8 stopUseMask = (ENCODE_REG_PC | thisLIR->useMask); + u8 stopDefMask = thisLIR->defMask; + u8 checkResult; /* First check if the load can be completely elinimated */ for (checkLIR = PREV_LIR(thisLIR); @@ -241,11 +242,27 @@ static void applyLoadHoisting(CompilationUnit *cUnit, /* * No earlier use/def can reach this load if: * 1) Head instruction is reached + */ + if (checkLIR == headLIR) { + break; + } + + checkResult = (stopUseMask | stopDefMask) & checkLIR->defMask; + + /* + * If both instructions are verified Dalvik accesses, clear the + * may- and must-alias bits to detect true resource + * dependencies. + */ + if (checkResult & ENCODE_DALVIK_REG) { + checkResult &= ~(ENCODE_DALVIK_REG | ENCODE_FRAME_REF); + } + + /* * 2) load target register is clobbered * 3) A branch is seen (stopUseMask has the PC bit set). */ - if ((checkLIR == headLIR) || - (stopUseMask | stopDefMask) & checkLIR->defMask) { + if (checkResult) { break; } @@ -300,11 +317,19 @@ static void applyLoadHoisting(CompilationUnit *cUnit, bool stopHere = (checkLIR == headLIR); /* Base address is clobbered by checkLIR */ - stopHere |= ((stopUseMask & checkLIR->defMask) != 0); + checkResult = stopUseMask & checkLIR->defMask; + if (checkResult & ENCODE_DALVIK_REG) { + checkResult &= ~(ENCODE_DALVIK_REG | ENCODE_FRAME_REF); + } + stopHere |= (checkResult != 0); /* Load target clobbers use/def in checkLIR */ - stopHere |= ((stopDefMask & - (checkLIR->useMask | checkLIR->defMask)) != 0); + checkResult = stopDefMask & + (checkLIR->useMask | checkLIR->defMask); + if (checkResult & ENCODE_DALVIK_REG) { + checkResult &= ~(ENCODE_DALVIK_REG | ENCODE_FRAME_REF); + } + stopHere |= (checkResult != 0); /* Store data partially clobbers the Dalvik register */ if (stopHere == false && @@ -341,15 +366,16 @@ static void applyLoadHoisting(CompilationUnit *cUnit, if (stopHere == true) { DEBUG_OPT(dumpDependentInsnPair(thisLIR, checkLIR, "HOIST LOAD")); - /* The store can be hoisted for at least one cycle */ + /* The load can be hoisted for at least one cycle */ if (hoistDistance != 0) { ArmLIR *newLoadLIR = dvmCompilerNew(sizeof(ArmLIR), true); *newLoadLIR = *thisLIR; newLoadLIR->age = cUnit->optRound; /* - * Insertion is guaranteed to succeed since checkLIR - * is never the first LIR on the list + * Stop point found - insert *after* the checkLIR + * since the instruction list is scanned in the + * bottom-up order. */ dvmCompilerInsertLIRAfter((LIR *) checkLIR, (LIR *) newLoadLIR); |
