diff options
| author | 2012-03-16 08:42:29 -0700 | |
|---|---|---|
| committer | 2012-03-17 16:52:32 -0700 | |
| commit | 239c4e72b5a69754e1d6879be5ba1f85150655c1 (patch) | |
| tree | 45404157d7a684a739d218dc5a9ee3c0a6cdab19 /src/compiler/codegen/RallocUtil.cc | |
| parent | 8ed14528fb70a9ba7cc5e471317d08dc629cbc23 (diff) | |
Loop detection, improved reg allocation
Detect loops and loop nesting depth, and use the latter to
weight register uses (which are then used to determine which
registers to promote).
Also:
o Fixed typo that prevented squashing of useless fp reg copies
o Rescheduled array access checks to hide latency of limit load.
o Add basic-block optimization pass to remove duplicate range
checks.
o Fixed bug that prevented recognition of redundant null
checks following iput-wide and aput-wide.
Change-Id: Icfbae39e89b1d14b8703ad6bbb0b29c0635fed1e
Diffstat (limited to 'src/compiler/codegen/RallocUtil.cc')
| -rw-r--r-- | src/compiler/codegen/RallocUtil.cc | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc index afbefff437..c08b2e883a 100644 --- a/src/compiler/codegen/RallocUtil.cc +++ b/src/compiler/codegen/RallocUtil.cc @@ -1043,52 +1043,31 @@ extern RegLocation oatGetSrcWide(CompilationUnit* cUnit, MIR* mir, void oatCountRefs(CompilationUnit *cUnit, BasicBlock* bb, RefCounts* coreCounts, RefCounts* fpCounts) { - MIR* mir; - if (bb->blockType != kDalvikByteCode && bb->blockType != kEntryBlock && - bb->blockType != kExitBlock) + if ((cUnit->disableOpt & (1 << kPromoteRegs)) || + !((bb->blockType == kEntryBlock) || (bb->blockType == kExitBlock) || + (bb->blockType == kDalvikByteCode))) { return; - - for (mir = bb->firstMIRInsn; mir; mir = mir->next) { - SSARepresentation *ssaRep = mir->ssaRep; - if (ssaRep) { - for (int i = 0; i < ssaRep->numDefs;) { - RegLocation loc = cUnit->regLocation[ssaRep->defs[i]]; - RefCounts* counts = loc.fp ? fpCounts : coreCounts; - int vReg = SRegToVReg(cUnit, ssaRep->defs[i]); - if (loc.defined) { - counts[vReg].count++; - } - if (loc.wide) { - if (loc.defined) { - if (loc.fp) { - counts[vReg].doubleStart = true; - } - counts[vReg+1].count++; - } - i += 2; - } else { - i++; - } - } - for (int i = 0; i < ssaRep->numUses;) { - RegLocation loc = cUnit->regLocation[ssaRep->uses[i]]; - RefCounts* counts = loc.fp ? fpCounts : coreCounts; - int vReg = SRegToVReg(cUnit, ssaRep->uses[i]); - if (loc.defined) { - counts[vReg].count++; - } - if (loc.wide) { - if (loc.defined) { - if (loc.fp) { - counts[vReg].doubleStart = true; - } - counts[vReg+1].count++; - } - i += 2; - } else { - i++; + } + for (int i = 0; i < cUnit->numSSARegs;) { + RegLocation loc = cUnit->regLocation[i]; + RefCounts* counts = loc.fp ? fpCounts : coreCounts; + int vReg = SRegToVReg(cUnit, loc.sRegLow); + if (vReg < 0) { + vReg = cUnit->numDalvikRegisters - (vReg + 1); + } + if (loc.defined) { + counts[vReg].count += cUnit->useCounts.elemList[i]; + } + if (loc.wide) { + if (loc.defined) { + if (loc.fp) { + counts[vReg].doubleStart = true; + counts[vReg+1].count += cUnit->useCounts.elemList[i+1]; } } + i += 2; + } else { + i++; } } } @@ -1115,7 +1094,9 @@ void oatDumpCounts(const RefCounts* arr, int size, const char* msg) */ extern void oatDoPromotion(CompilationUnit* cUnit) { - int numRegs = cUnit->numDalvikRegisters; + int regBias = cUnit->numCompilerTemps + 1; + int dalvikRegs = cUnit->numDalvikRegisters; + int numRegs = dalvikRegs + regBias; // Allow target code to add any special registers oatAdjustSpillMask(cUnit); @@ -1135,9 +1116,14 @@ extern void oatDoPromotion(CompilationUnit* cUnit) oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc); RefCounts *fpRegs = (RefCounts *) oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc); - for (int i = 0; i < numRegs; i++) { + // Set ssa names for original Dalvik registers + for (int i = 0; i < dalvikRegs; i++) { coreRegs[i].sReg = fpRegs[i].sReg = i; } + // Set ssa names for Method* and compiler temps + for (int i = 0; i < regBias; i++) { + coreRegs[dalvikRegs + i].sReg = fpRegs[dalvikRegs + i].sReg = (-1 - i); + } GrowableListIterator iterator; oatGrowableListIteratorInit(&cUnit->blockList, &iterator); while (true) { |