Shortcut identical consecutive conditional branches
This commit is contained in:
parent
5696691a19
commit
1a06102668
|
@ -114,6 +114,7 @@ inline void sidfx_loop_ch(byte ch)
|
||||||
{
|
{
|
||||||
channels[ch].cnt--;
|
channels[ch].cnt--;
|
||||||
channels[ch].com++;
|
channels[ch].com++;
|
||||||
|
channels[ch].priority = channels[ch].com->priority;
|
||||||
channels[ch].state = SIDFX_READY;
|
channels[ch].state = SIDFX_READY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -140,6 +141,7 @@ inline void sidfx_loop_ch(byte ch)
|
||||||
{
|
{
|
||||||
channels[ch].cnt--;
|
channels[ch].cnt--;
|
||||||
channels[ch].com++;
|
channels[ch].com++;
|
||||||
|
channels[ch].priority = channels[ch].com->priority;
|
||||||
channels[ch].state = SIDFX_RESET_0;
|
channels[ch].state = SIDFX_RESET_0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -4060,6 +4060,32 @@ void InterCodeBasicBlock::GenerateTraces(bool expand, bool compact)
|
||||||
if (mFalseJump)
|
if (mFalseJump)
|
||||||
mFalseJump->mNumEntries++;
|
mFalseJump->mNumEntries++;
|
||||||
}
|
}
|
||||||
|
else if (
|
||||||
|
mTrueJump &&
|
||||||
|
mInstructions.Size() > 0 &&
|
||||||
|
mInstructions.Last()->mCode == IC_BRANCH &&
|
||||||
|
mTrueJump->mInstructions.Size() == 1 &&
|
||||||
|
mTrueJump->mInstructions[0]->mCode == IC_BRANCH &&
|
||||||
|
mTrueJump->mInstructions[0]->mSrc[0].mTemp == mInstructions.Last()->mSrc[0].mTemp)
|
||||||
|
{
|
||||||
|
mTrueJump->mNumEntries--;
|
||||||
|
mTrueJump = mTrueJump->mTrueJump;
|
||||||
|
if (mTrueJump)
|
||||||
|
mTrueJump->mNumEntries++;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
mFalseJump &&
|
||||||
|
mInstructions.Size() > 0 &&
|
||||||
|
mInstructions.Last()->mCode == IC_BRANCH &&
|
||||||
|
mFalseJump->mInstructions.Size() == 1 &&
|
||||||
|
mFalseJump->mInstructions[0]->mCode == IC_BRANCH &&
|
||||||
|
mFalseJump->mInstructions[0]->mSrc[0].mTemp == mInstructions.Last()->mSrc[0].mTemp)
|
||||||
|
{
|
||||||
|
mFalseJump->mNumEntries--;
|
||||||
|
mFalseJump = mFalseJump->mFalseJump;
|
||||||
|
if (mFalseJump)
|
||||||
|
mFalseJump->mNumEntries++;
|
||||||
|
}
|
||||||
else if (mTrueJump && !mFalseJump && ((expand && mTrueJump->mInstructions.Size() < 10 && mTrueJump->mInstructions.Size() > 1 && !mLoopHead) || mTrueJump->mNumEntries == 1) && !mTrueJump->mLoopHead && !IsInfiniteLoop(mTrueJump, mTrueJump))
|
else if (mTrueJump && !mFalseJump && ((expand && mTrueJump->mInstructions.Size() < 10 && mTrueJump->mInstructions.Size() > 1 && !mLoopHead) || mTrueJump->mNumEntries == 1) && !mTrueJump->mLoopHead && !IsInfiniteLoop(mTrueJump, mTrueJump))
|
||||||
{
|
{
|
||||||
mTrueJump->mNumEntries--;
|
mTrueJump->mNumEntries--;
|
||||||
|
|
|
@ -16780,27 +16780,27 @@ bool NativeCodeBasicBlock::CheckPatchFailUse(void)
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg)
|
bool NativeCodeBasicBlock::CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg)
|
||||||
{
|
{
|
||||||
if (mPatched)
|
if (mPatched && mEntryRequiredRegs[reg])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!mPatchFail)
|
if (!mPatchFail)
|
||||||
{
|
{
|
||||||
mPatchFail = true;
|
mPatchFail = true;
|
||||||
|
|
||||||
|
if (this != block)
|
||||||
|
{
|
||||||
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg))
|
if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles)
|
bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles)
|
||||||
{
|
{
|
||||||
if (mPatchFail)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!mPatched)
|
if (!mPatched)
|
||||||
{
|
{
|
||||||
if (at == 0)
|
if (at == 0)
|
||||||
|
@ -16809,7 +16809,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
||||||
|
|
||||||
if (!mEntryRequiredRegs[reg])
|
if (!mEntryRequiredRegs[reg])
|
||||||
{
|
{
|
||||||
if (mExitRequiredRegs[reg])
|
mPatchFail = true;
|
||||||
|
|
||||||
|
// if (mExitRequiredRegs[reg])
|
||||||
{
|
{
|
||||||
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg))
|
||||||
return false;
|
return false;
|
||||||
|
@ -16832,6 +16834,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPatchFail)
|
||||||
|
return false;
|
||||||
|
|
||||||
while (at < mIns.Size())
|
while (at < mIns.Size())
|
||||||
{
|
{
|
||||||
NativeCodeInstruction& ins(mIns[at]);
|
NativeCodeInstruction& ins(mIns[at]);
|
||||||
|
@ -25301,6 +25306,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass
|
||||||
|
|
||||||
CheckLive();
|
CheckLive();
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
#if 1
|
#if 1
|
||||||
// move load store pairs up to initial store
|
// move load store pairs up to initial store
|
||||||
|
@ -31826,7 +31832,8 @@ void NativeCodeProcedure::RebuildEntry(void)
|
||||||
|
|
||||||
void NativeCodeProcedure::Optimize(void)
|
void NativeCodeProcedure::Optimize(void)
|
||||||
{
|
{
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "chain_prepend");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "main");
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
int step = 0;
|
int step = 0;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
@ -31995,6 +32002,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
if (mEntryBlock->RemoveDoubleZPStore())
|
if (mEntryBlock->RemoveDoubleZPStore())
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (step > 0)
|
if (step > 0)
|
||||||
{
|
{
|
||||||
|
@ -32046,7 +32054,6 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
mEntryBlock->CheckBlocks(true);
|
mEntryBlock->CheckBlocks(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (step > 2 && !changed)
|
if (step > 2 && !changed)
|
||||||
{
|
{
|
||||||
|
@ -32295,6 +32302,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (step == 7)
|
if (step == 7)
|
||||||
{
|
{
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
|
@ -32337,6 +32345,8 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
else
|
else
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
Loading…
Reference in New Issue