Fix loss of zero page dependency in tail code merge

This commit is contained in:
drmortalwombat 2023-12-17 12:40:09 +01:00
parent ae4b48c445
commit 4a8010a3a0
2 changed files with 8 additions and 5 deletions

View File

@ -16789,6 +16789,7 @@ bool InterCodeBasicBlock::PeepholeReplaceOptimization(const GrowingVariableArray
mInstructions[i + 2]->mSrc[0].mType == IT_INT8) mInstructions[i + 2]->mSrc[0].mType == IT_INT8)
{ {
mInstructions[i + 1]->mSrc[1] = mInstructions[i + 0]->mSrc[0]; mInstructions[i + 1]->mSrc[1] = mInstructions[i + 0]->mSrc[0];
mInstructions[i + 0]->mSrc[0].mFinal = false;
mInstructions[i + 1]->mDst.mType = IT_INT8; mInstructions[i + 1]->mDst.mType = IT_INT8;
changed = true; changed = true;
@ -16807,6 +16808,7 @@ bool InterCodeBasicBlock::PeepholeReplaceOptimization(const GrowingVariableArray
mInstructions[i + 2]->mSrc[0].mType == IT_INT8) mInstructions[i + 2]->mSrc[0].mType == IT_INT8)
{ {
mInstructions[i + 1]->mSrc[0] = mInstructions[i + 0]->mSrc[0]; mInstructions[i + 1]->mSrc[0] = mInstructions[i + 0]->mSrc[0];
mInstructions[i + 0]->mSrc[0].mFinal = false;
mInstructions[i + 1]->mDst.mType = IT_INT8; mInstructions[i + 1]->mDst.mType = IT_INT8;
changed = true; changed = true;
@ -19139,7 +19141,7 @@ void InterCodeProcedure::Close(void)
{ {
GrowingTypeArray tstack(IT_NONE); GrowingTypeArray tstack(IT_NONE);
CheckFunc = !strcmp(mIdent->mString, "main"); CheckFunc = !strcmp(mIdent->mString, "interpret_statement");
CheckCase = false; CheckCase = false;
mEntryBlock = mBlocks[0]; mEntryBlock = mBlocks[0];
@ -20303,7 +20305,7 @@ bool InterCodeBasicBlock::SameExitCode(const InterCodeBasicBlock* block) const
{ {
if (mInstructions[j0]->mCode == IC_LEA && mInstructions[j0]->mSrc[1].mTemp < 0) if (mInstructions[j0]->mCode == IC_LEA && mInstructions[j0]->mSrc[1].mTemp < 0)
return false; return false;
if (block->mInstructions[j1]->mCode == IC_LEA && mInstructions[j1]->mSrc[1].mTemp < 0) if (block->mInstructions[j1]->mCode == IC_LEA && block->mInstructions[j1]->mSrc[1].mTemp < 0)
return false; return false;
} }
} }

View File

@ -21816,8 +21816,8 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool
{ {
if (!mTrueJump->mIns[0].ChangesCarry() && mTrueJump->mIns[0].IsSame(mFalseJump->mIns[0])) if (!mTrueJump->mIns[0].ChangesCarry() && mTrueJump->mIns[0].IsSame(mFalseJump->mIns[0]))
{ {
int live = mTrueJump->mIns[0].mLive; int live = mTrueJump->mIns[0].mLive | mFalseJump->mIns[0].mLive;
mTrueJump->mIns[0].mLive |= LIVE_CPU_REG_C; mTrueJump->mIns[0].mLive |= LIVE_CPU_REG_C | live;
mIns.Push(mTrueJump->mIns[0]); mIns.Push(mTrueJump->mIns[0]);
mTrueJump->mIns.Remove(0); mTrueJump->mIns.Remove(0);
mFalseJump->mIns.Remove(0); mFalseJump->mIns.Remove(0);
@ -44723,7 +44723,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
{ {
mInterProc = proc; mInterProc = proc;
CheckFunc = !strcmp(mInterProc->mIdent->mString, "mh_size"); CheckFunc = !strcmp(mInterProc->mIdent->mString, "interpret_builtin");
int nblocks = proc->mBlocks.Size(); int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks]; tblocks = new NativeCodeBasicBlock * [nblocks];
@ -45664,6 +45664,7 @@ void NativeCodeProcedure::Optimize(void)
changed = true; changed = true;
} }
if (step > 2 && !changed) if (step > 2 && !changed)
{ {
ResetVisited(); ResetVisited();