diff --git a/include/audio/sidfx.c b/include/audio/sidfx.c index ca3a781..e2e5a5e 100644 --- a/include/audio/sidfx.c +++ b/include/audio/sidfx.c @@ -114,6 +114,7 @@ inline void sidfx_loop_ch(byte ch) { channels[ch].cnt--; channels[ch].com++; + channels[ch].priority = channels[ch].com->priority; channels[ch].state = SIDFX_READY; } else @@ -140,6 +141,7 @@ inline void sidfx_loop_ch(byte ch) { channels[ch].cnt--; channels[ch].com++; + channels[ch].priority = channels[ch].com->priority; channels[ch].state = SIDFX_RESET_0; } else diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index 3dc886a..475529a 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -4060,6 +4060,32 @@ void InterCodeBasicBlock::GenerateTraces(bool expand, bool compact) if (mFalseJump) 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)) { mTrueJump->mNumEntries--; diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 43bb1de..8f8502f 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -16780,17 +16780,20 @@ bool NativeCodeBasicBlock::CheckPatchFailUse(void) bool NativeCodeBasicBlock::CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg) { - if (mPatched) + if (mPatched && mEntryRequiredRegs[reg]) return false; if (!mPatchFail) { mPatchFail = true; - if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg)) - return false; - if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg)) - return false; + if (this != block) + { + if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg)) + return false; + if (mFalseJump && !mFalseJump->CheckPatchFailReg(block, reg)) + return false; + } } return true; @@ -16798,9 +16801,6 @@ bool NativeCodeBasicBlock::CheckPatchFailReg(const NativeCodeBasicBlock* block, bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles) { - if (mPatchFail) - return false; - if (!mPatched) { if (at == 0) @@ -16809,7 +16809,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* if (!mEntryRequiredRegs[reg]) { - if (mExitRequiredRegs[reg]) + mPatchFail = true; + +// if (mExitRequiredRegs[reg]) { if (mTrueJump && !mTrueJump->CheckPatchFailReg(block, reg)) return false; @@ -16832,6 +16834,9 @@ bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* } } + if (mPatchFail) + return false; + while (at < mIns.Size()) { NativeCodeInstruction& ins(mIns[at]); @@ -25301,6 +25306,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass CheckLive(); + #if 1 #if 1 // move load store pairs up to initial store @@ -31826,7 +31832,8 @@ void NativeCodeProcedure::RebuildEntry(void) void NativeCodeProcedure::Optimize(void) { - CheckFunc = !strcmp(mInterProc->mIdent->mString, "chain_prepend"); + CheckFunc = !strcmp(mInterProc->mIdent->mString, "main"); + #if 1 int step = 0; int cnt = 0; @@ -31995,6 +32002,7 @@ void NativeCodeProcedure::Optimize(void) if (mEntryBlock->RemoveDoubleZPStore()) changed = true; } + #if 1 if (step > 0) { @@ -32046,7 +32054,6 @@ void NativeCodeProcedure::Optimize(void) mEntryBlock->CheckBlocks(true); #endif - #if 1 if (step > 2 && !changed) { @@ -32295,6 +32302,7 @@ void NativeCodeProcedure::Optimize(void) changed = true; } #endif + if (step == 7) { ResetVisited(); @@ -32337,6 +32345,8 @@ void NativeCodeProcedure::Optimize(void) else cnt++; + + } while (changed); #if 1