Remove needless register transfers from inner loops
This commit is contained in:
parent
2a476d3372
commit
4acee4531c
|
@ -39809,6 +39809,34 @@ bool NativeCodeBasicBlock::OptimizeSingleEntryLoopInvariant(NativeCodeProcedure*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!changed)
|
||||||
|
{
|
||||||
|
if (mIns.Size() > 0 && mIns[0].mType == ASMIT_TXA)
|
||||||
|
{
|
||||||
|
if (!ChangesAccu(1) && !ChangesXReg(1))
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (i < lblocks.Size() && (lblocks[i] == this || (!lblocks[i]->ChangesXReg() && !lblocks[i]->ChangesAccu())))
|
||||||
|
i++;
|
||||||
|
if (i == lblocks.Size())
|
||||||
|
{
|
||||||
|
prev->mIns.Push(mIns[0]);
|
||||||
|
mIns.Remove(0);
|
||||||
|
prev->mExitRequiredRegs += CPU_REG_A;
|
||||||
|
mEntryRequiredRegs += CPU_REG_A;
|
||||||
|
mExitRequiredRegs += CPU_REG_A;
|
||||||
|
|
||||||
|
for (int i = 0; i < lblocks.Size(); i++)
|
||||||
|
{
|
||||||
|
lblocks[i]->mEntryRequiredRegs += CPU_REG_A;
|
||||||
|
lblocks[i]->mExitRequiredRegs += CPU_REG_A;
|
||||||
|
}
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
if (mIns.Size() > 0 && mIns[0].mType == ASMIT_LDY && mIns[0].mMode == ASMIM_ZERO_PAGE)
|
if (mIns.Size() > 0 && mIns[0].mType == ASMIT_LDY && mIns[0].mMode == ASMIM_ZERO_PAGE)
|
||||||
|
@ -51718,7 +51746,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
||||||
mInterProc = proc;
|
mInterProc = proc;
|
||||||
mInterProc->mLinkerObject->mNativeProc = this;
|
mInterProc->mLinkerObject->mNativeProc = this;
|
||||||
|
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "status_draw_map");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "main");
|
||||||
|
|
||||||
int nblocks = proc->mBlocks.Size();
|
int nblocks = proc->mBlocks.Size();
|
||||||
tblocks = new NativeCodeBasicBlock * [nblocks];
|
tblocks = new NativeCodeBasicBlock * [nblocks];
|
||||||
|
@ -52892,7 +52920,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
CheckBlocks();
|
CheckBlocks();
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (step == 3 || step == 4 || (step == 15 && cnt > 0))
|
if (step == 3 || step == 4 || step == 8 || (step == 15 && cnt > 0))
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
|
@ -53549,7 +53577,6 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
mEntryBlock->CombineAlternateLoads();
|
mEntryBlock->CombineAlternateLoads();
|
||||||
|
|
Loading…
Reference in New Issue