Fix compare reversal and reuse if z flag used

This commit is contained in:
drmortalwombat 2025-03-07 08:17:51 +01:00
parent 2582f3076d
commit 490180f9dc

View File

@ -25625,6 +25625,13 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool
mIns[nins - 1].mLive |= LIVE_CPU_REG_A; mIns[nins - 1].mLive |= LIVE_CPU_REG_A;
mExitRequiredRegs += CPU_REG_A; mExitRequiredRegs += CPU_REG_A;
mTrueJump->mEntryRequiredRegs += CPU_REG_A; mTrueJump->mEntryRequiredRegs += CPU_REG_A;
if (mTrueJump->mIns[0].mLive & LIVE_CPU_REG_Z)
{
mTrueJump->mIns[0].mType = ASMIT_ORA;
mTrueJump->mIns[0].mMode = ASMIM_IMMEDIATE;
mTrueJump->mIns[0].mAddress = 0;
}
else
mTrueJump->mIns.Remove(0); mTrueJump->mIns.Remove(0);
changed = true; changed = true;
@ -25637,6 +25644,13 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool
mIns[nins - 1].mLive |= LIVE_CPU_REG_A; mIns[nins - 1].mLive |= LIVE_CPU_REG_A;
mExitRequiredRegs += CPU_REG_A; mExitRequiredRegs += CPU_REG_A;
mFalseJump->mEntryRequiredRegs += CPU_REG_A; mFalseJump->mEntryRequiredRegs += CPU_REG_A;
if (mFalseJump->mIns[0].mLive & LIVE_CPU_REG_Z)
{
mFalseJump->mIns[0].mType = ASMIT_ORA;
mFalseJump->mIns[0].mMode = ASMIM_IMMEDIATE;
mFalseJump->mIns[0].mAddress = 0;
}
else
mFalseJump->mIns.Remove(0); mFalseJump->mIns.Remove(0);
changed = true; changed = true;
@ -53253,7 +53267,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mInterProc->mLinkerObject->mNativeProc = this; mInterProc->mLinkerObject->mNativeProc = this;
CheckFunc = !strcmp(mIdent->mString, "shots_hide"); CheckFunc = !strcmp(mIdent->mString, "doScroll");
int nblocks = proc->mBlocks.Size(); int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks]; tblocks = new NativeCodeBasicBlock * [nblocks];