Fix infinite optimizer loop
This commit is contained in:
parent
ba2a90030c
commit
6af03b34ad
|
@ -12715,6 +12715,7 @@ bool InterCodeBasicBlock::PeepholeReplaceOptimization(const GrowingVariableArray
|
|||
|
||||
mInstructions[i + 1]->mCode = IC_BINARY_OPERATOR;
|
||||
mInstructions[i + 1]->mOperator = IA_AND;
|
||||
mInstructions[i + 1]->mNumOperands = 2;
|
||||
mInstructions[i + 1]->mSrc[0].mType = IT_INT16;
|
||||
mInstructions[i + 1]->mSrc[1].mType = IT_INT16;
|
||||
mInstructions[i + 1]->mSrc[1].mTemp = -1;
|
||||
|
|
|
@ -16509,7 +16509,7 @@ bool NativeCodeBasicBlock::ReduceLocalXPressure(void)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool NativeCodeBasicBlock::CombineZPPair(int at, int r0, int r1, bool use0, bool use1)
|
||||
bool NativeCodeBasicBlock::CombineZPPair(int at, int r0, int r1, bool use0, bool use1, bool & used1)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
@ -16561,6 +16561,8 @@ bool NativeCodeBasicBlock::CombineZPPair(int at, int r0, int r1, bool use0, bool
|
|||
|
||||
bool valid0 = true, valid1 = true;
|
||||
|
||||
used1 = use1;
|
||||
|
||||
i = at;
|
||||
while (i < mIns.Size() && valid0 && valid1)
|
||||
{
|
||||
|
@ -16618,27 +16620,47 @@ bool NativeCodeBasicBlock::RemoveDoubleZPStore(void)
|
|||
{
|
||||
mVisited = true;
|
||||
|
||||
bool swap;
|
||||
|
||||
for (int i = 0; i + 1 < mIns.Size(); i++)
|
||||
{
|
||||
if (mIns[i + 0].mType == ASMIT_STX && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
|
||||
mIns[i + 1].mType == ASMIT_STX && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 0].mAddress != mIns[i + 1].mAddress)
|
||||
{
|
||||
if (CombineZPPair(i + 2, mIns[i + 0].mAddress, mIns[i + 1].mAddress, false, false))
|
||||
if (CombineZPPair(i + 2, mIns[i + 0].mAddress, mIns[i + 1].mAddress, false, false, swap))
|
||||
{
|
||||
if (swap)
|
||||
{
|
||||
int a = mIns[i + 0].mAddress; mIns[i + 0].mAddress = mIns[i + 1].mAddress; mIns[i + 1].mAddress = a;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (mIns[i + 0].mType == ASMIT_STA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
|
||||
mIns[i + 1].mType == ASMIT_STA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 0].mAddress != mIns[i + 1].mAddress)
|
||||
{
|
||||
if (CombineZPPair(i + 2, mIns[i + 0].mAddress, mIns[i + 1].mAddress, false, false))
|
||||
if (CombineZPPair(i + 2, mIns[i + 0].mAddress, mIns[i + 1].mAddress, false, false, swap))
|
||||
{
|
||||
if (swap)
|
||||
{
|
||||
int a = mIns[i + 0].mAddress; mIns[i + 0].mAddress = mIns[i + 1].mAddress; mIns[i + 1].mAddress = a;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (mIns[i + 0].mType == ASMIT_STY && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
|
||||
mIns[i + 1].mType == ASMIT_STY && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 0].mAddress != mIns[i + 1].mAddress)
|
||||
{
|
||||
if (CombineZPPair(i + 2, mIns[i + 0].mAddress, mIns[i + 1].mAddress, false, false))
|
||||
if (CombineZPPair(i + 2, mIns[i + 0].mAddress, mIns[i + 1].mAddress, false, false, swap))
|
||||
{
|
||||
if (swap)
|
||||
{
|
||||
int a = mIns[i + 0].mAddress; mIns[i + 0].mAddress = mIns[i + 1].mAddress; mIns[i + 1].mAddress = a;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mTrueJump && mTrueJump->RemoveDoubleZPStore())
|
||||
changed = true;
|
||||
|
@ -18519,7 +18541,7 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool
|
|||
}
|
||||
}
|
||||
|
||||
if (mIns[0].mType == ASMIT_LDY && mIns[0].mMode == ASMIM_ZERO_PAGE)
|
||||
if (!changed && mIns[0].mType == ASMIT_LDY && mIns[0].mMode == ASMIM_ZERO_PAGE)
|
||||
{
|
||||
if (lblock->mIns[ls - 2].mType == ASMIT_STY && lblock->mIns[ls - 2].mMode == ASMIM_ZERO_PAGE && lblock->mIns[ls - 2].mAddress == mIns[0].mAddress && lblock->mIns[ls - 1].mType == ASMIT_CPY)
|
||||
{
|
||||
|
@ -19893,6 +19915,7 @@ bool NativeCodeBasicBlock::BypassRegisterConditionBlock(void)
|
|||
changed = true;
|
||||
mExitRequiredRegs -= CPU_REG_A;
|
||||
mExitRequiredRegs += CPU_REG_X;
|
||||
cblock->mEntryRequiredRegs += CPU_REG_X;
|
||||
}
|
||||
}
|
||||
else if (i >= 0 && mIns[i].mType == ASMIT_TYA && !(mIns[i].mLive & LIVE_CPU_REG_Z))
|
||||
|
@ -19904,6 +19927,7 @@ bool NativeCodeBasicBlock::BypassRegisterConditionBlock(void)
|
|||
changed = true;
|
||||
mExitRequiredRegs -= CPU_REG_A;
|
||||
mExitRequiredRegs += CPU_REG_Y;
|
||||
cblock->mEntryRequiredRegs += CPU_REG_Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23577,11 +23601,21 @@ bool NativeCodeBasicBlock::MoveLoadStoreOutOfXYRangeUp(int at)
|
|||
j--;
|
||||
mIns.Insert(j, mIns[at + 2]);
|
||||
mIns.Insert(j, mIns[at + 2]);
|
||||
int live = 0;
|
||||
|
||||
if (j > 0)
|
||||
live = mIns[j - 1].mLive;
|
||||
else
|
||||
{
|
||||
mIns[j].mLive |= mIns[j - 1].mLive;
|
||||
mIns[j + 1].mLive |= mIns[j - 1].mLive;
|
||||
if (mEntryRequiredRegs[CPU_REG_X])
|
||||
live |= LIVE_CPU_REG_X;
|
||||
if (mEntryRequiredRegs[CPU_REG_Y])
|
||||
live |= LIVE_CPU_REG_Y;
|
||||
}
|
||||
|
||||
mIns[j].mLive |= live;
|
||||
mIns[j + 1].mLive |= live;
|
||||
|
||||
mIns.Remove(at + 3);
|
||||
mIns.Remove(at + 3);
|
||||
|
||||
|
|
|
@ -497,7 +497,7 @@ public:
|
|||
bool ReduceLocalYPressure(void);
|
||||
bool ReduceLocalXPressure(void);
|
||||
|
||||
bool CombineZPPair(int at, int r0, int r1, bool use0, bool use1);
|
||||
bool CombineZPPair(int at, int r0, int r1, bool use0, bool use1, bool & swap);
|
||||
bool RemoveDoubleZPStore(void);
|
||||
|
||||
bool ExpandADCToBranch(NativeCodeProcedure* proc);
|
||||
|
|
Loading…
Reference in New Issue