Fix complex diamond pointer forwarding

Forwarding failed when pointer was used and modified in one branch of the diamond
This commit is contained in:
drmortalwombat 2024-10-31 22:48:34 +01:00
parent db386a5958
commit 3c129ff4e5

View File

@ -29333,8 +29333,12 @@ bool NativeCodeBasicBlock::CheckGlobalAddressSumYPointer(const NativeCodeBasicBl
return false; return false;
else if (!(ins.mLive & LIVE_MEM)) else if (!(ins.mLive & LIVE_MEM))
{ {
if (mPatchFail)
return false;
mPatchChecked = true; mPatchChecked = true;
return !mPatchFail; if (mTrueJump && !mTrueJump->CheckPatchFailUse() || mFalseJump && !mFalseJump->CheckPatchFailUse())
return false;
return true;
} }
} }
@ -48276,6 +48280,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate6(int i, int pass)
return true; return true;
} }
#if 1
if (pass == 0 && if (pass == 0 &&
mIns[i + 0].mType == ASMIT_CLC && mIns[i + 0].mType == ASMIT_CLC &&
mIns[i + 1].mType == ASMIT_ADC && mIns[i + 1].mMode == ASMIM_IMMEDIATE_ADDRESS && (mIns[i + 1].mFlags & NCIF_LOWER) && mIns[i + 1].mType == ASMIT_ADC && mIns[i + 1].mMode == ASMIM_IMMEDIATE_ADDRESS && (mIns[i + 1].mFlags & NCIF_LOWER) &&
@ -48301,7 +48306,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate6(int i, int pass)
return true; return true;
} }
} }
#endif
if (pass == 0 && if (pass == 0 &&
mIns[i + 0].mType == ASMIT_CLC && mIns[i + 0].mType == ASMIT_CLC &&
mIns[i + 1].mType == ASMIT_ADC && mIns[i + 1].mMode == ASMIM_IMMEDIATE && mIns[i + 1].mType == ASMIT_ADC && mIns[i + 1].mMode == ASMIM_IMMEDIATE &&
@ -49634,6 +49639,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate(int pass)
mTrueJump->CheckLive(); mTrueJump->CheckLive();
if (mFalseJump) if (mFalseJump)
mFalseJump->CheckLive(); mFalseJump->CheckLive();
#if 1 #if 1
if (pass < 10 && i + 1 < mIns.Size()) if (pass < 10 && i + 1 < mIns.Size())
{ {
@ -49734,8 +49740,10 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate(int pass)
if (mFalseJump) if (mFalseJump)
mFalseJump->CheckLive(); mFalseJump->CheckLive();
#if 1
if (i + 5 < mIns.Size() && PeepHoleOptimizerIterate6(i, pass)) progress = true; if (i + 5 < mIns.Size() && PeepHoleOptimizerIterate6(i, pass)) progress = true;
CheckLive(); CheckLive();
#endif
#if 1 #if 1
if (i + 3 < mIns.Size() && pass == 0 && if (i + 3 < mIns.Size() && pass == 0 &&
@ -49754,6 +49762,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate(int pass)
} }
} }
#endif #endif
#if 1
if (i + 2 < mIns.Size() && pass == 0 && if (i + 2 < mIns.Size() && pass == 0 &&
mIns[i + 0].mType == ASMIT_STA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && mIns[i + 0].mType == ASMIT_STA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_IMMEDIATE && mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_IMMEDIATE &&
@ -49771,7 +49780,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate(int pass)
progress = true; progress = true;
} }
} }
#endif
#if 1 #if 1
if (i + 1 < mIns.Size() && if (i + 1 < mIns.Size() &&
mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_IMMEDIATE_ADDRESS && (mIns[i + 0].mFlags & NCIF_UPPER) && mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_IMMEDIATE_ADDRESS && (mIns[i + 0].mFlags & NCIF_UPPER) &&
@ -49935,6 +49944,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerIterate(int pass)
mTrueJump->CheckLive(); mTrueJump->CheckLive();
if (mFalseJump) if (mFalseJump)
mFalseJump->CheckLive(); mFalseJump->CheckLive();
} }
if (progress) if (progress)
@ -51678,7 +51688,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mInterProc = proc; mInterProc = proc;
mInterProc->mLinkerObject->mNativeProc = this; mInterProc->mLinkerObject->mNativeProc = this;
CheckFunc = !strcmp(mInterProc->mIdent->mString, "floor_prepare"); CheckFunc = !strcmp(mInterProc->mIdent->mString, "__prepareScreen__");
int nblocks = proc->mBlocks.Size(); int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks]; tblocks = new NativeCodeBasicBlock * [nblocks];
@ -52648,6 +52658,7 @@ void NativeCodeProcedure::Optimize(void)
CheckBlocks(); CheckBlocks();
#if 1 #if 1
ResetVisited(); ResetVisited();
if (mEntryBlock->PeepHoleOptimizer(step)) if (mEntryBlock->PeepHoleOptimizer(step))