From d4a9308627a26247895be67f4ff39f20dc1a2063 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:38:56 +0100 Subject: [PATCH] More inter code value forwarding --- oscar64/InterCode.cpp | 8 +++++++- oscar64/NativeCodeGenerator.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index 2ce8eba..a465144 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -7096,6 +7096,7 @@ void InterCodeProcedure::Close(void) bool eliminated; + int retries = 2; // // Now forward constant values // @@ -7119,7 +7120,12 @@ void InterCodeProcedure::Close(void) mEntryBlock->CollectEntries(); */ } - } while (eliminated); + + mTemporaries.SetSize(numTemps, true); + TempForwarding(); + retries--; + + } while (eliminated || retries > 0); DisassembleDebug("value forwarding"); diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index b6995bd..274840a 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -9355,6 +9355,12 @@ bool NativeCodeBasicBlock::PatchDirectAddressSumY(int at, int reg, int apos, int if (last == mIns.Size()) return false; + if (mIns[last].mLive & LIVE_CPU_REG_Y) + { + mIns.Insert(last + 1, NativeCodeInstruction(ASMIT_LDY, ASMIM_IMMEDIATE, yindex)); + mIns[last + 1].mLive |= CPU_REG_Y; + } + mIns[apos].mType = ASMIT_TAY; for (int i = 0; i < 5; i++) {