Fix address/register mismatch in 16bit sum forwarding

This commit is contained in:
drmortalwombat 2024-10-22 13:21:16 +02:00
parent d597219aea
commit 7e0ff7449c

View File

@ -33026,7 +33026,9 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
if (info.mAddress == mRSumInfos[j].mAddress) if (info.mAddress == mRSumInfos[j].mAddress)
{ {
info.mSrcL->mAddress = mRSumInfos[j].mDstL->mAddress; info.mSrcL->mAddress = mRSumInfos[j].mDstL->mAddress;
info.mSrcL->mMode = mRSumInfos[j].mDstL->mMode;
info.mSrcH->mAddress = mRSumInfos[j].mDstH->mAddress; info.mSrcH->mAddress = mRSumInfos[j].mDstH->mAddress;
info.mSrcH->mMode = mRSumInfos[j].mDstH->mMode;
info.mAddL->mType = ASMIT_NOP; info.mAddL->mMode = ASMIM_IMPLIED; info.mAddL->mType = ASMIT_NOP; info.mAddL->mMode = ASMIM_IMPLIED;
info.mAddH->mType = ASMIT_NOP; info.mAddH->mMode = ASMIM_IMPLIED; info.mAddH->mType = ASMIT_NOP; info.mAddH->mMode = ASMIM_IMPLIED;
changed = true; changed = true;
@ -46122,6 +46124,15 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate3(int i, int pass)
return true; return true;
} }
if (mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_IMMEDIATE && !(mIns[i + 0].mAddress & 1) &&
mIns[i + 1].mType == ASMIT_ADC && mIns[i + 1].mMode == ASMIM_IMMEDIATE && mIns[i + 1].mAddress == 0 &&
mIns[i + 2].mType == ASMIT_ORA && mIns[i + 2].mMode == ASMIM_IMMEDIATE && !(mIns[i + 2].mAddress & 1))
{
mIns[i + 0].mAddress |= mIns[i + 2].mAddress;
mIns[i + 2].mType = ASMIT_NOP; mIns[i + 2].mMode = ASMIM_IMPLIED;
return true;
}
if ( if (
mIns[i + 0].mType == ASMIT_LDY && mIns[i + 0].mMode == ASMIM_IMMEDIATE && mIns[i + 0].mAddress <= 1 && mIns[i + 0].mType == ASMIT_LDY && mIns[i + 0].mMode == ASMIM_IMMEDIATE && mIns[i + 0].mAddress <= 1 &&
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mType == ASMIT_LDA &&
@ -51552,7 +51563,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mInterProc = proc; mInterProc = proc;
mInterProc->mLinkerObject->mNativeProc = this; mInterProc->mLinkerObject->mNativeProc = this;
CheckFunc = !strcmp(mInterProc->mIdent->mString, "walker_draw_right"); CheckFunc = !strcmp(mInterProc->mIdent->mString, "room_prep_chest");
int nblocks = proc->mBlocks.Size(); int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks]; tblocks = new NativeCodeBasicBlock * [nblocks];
@ -52414,7 +52425,6 @@ void NativeCodeProcedure::Optimize(void)
mEntryBlock->CheckAsmCode(); mEntryBlock->CheckAsmCode();
#endif #endif
int t = 0; int t = 0;
#if 1 #if 1
do do
@ -52511,6 +52521,7 @@ void NativeCodeProcedure::Optimize(void)
if (mEntryBlock->PeepHoleOptimizer(step)) if (mEntryBlock->PeepHoleOptimizer(step))
changed = true; changed = true;
#endif #endif
if (step == 2) if (step == 2)
{ {