From 42299c940647842e507ecfd213fe43b719a65fba Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sat, 10 May 2025 10:50:42 +0200 Subject: [PATCH] Improve const to immediate propagation --- oscar64/NativeCodeGenerator.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 4067ebb..c272469 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -46032,6 +46032,16 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerShuffle(int pass) bool NativeCodeBasicBlock::PeepHoleOptimizerIterate1(int i, int pass) { + if (mIns[i].mMode == ASMIM_ABSOLUTE && mIns[i].mLinkerObject && (mIns[i].mLinkerObject->mFlags & LOBJF_CONST) && + mIns[i].mLinkerObject->mReferences.Size() == 0 && + !mIns[i].ChangesAddress() && HasAsmInstructionMode(mIns[i].mType, ASMIM_IMMEDIATE)) + { + mIns[i].mMode = ASMIM_IMMEDIATE; + mIns[i].mAddress = mIns[i].mLinkerObject->mData[mIns[i].mAddress]; + mIns[i].mLinkerObject = nullptr; + return true; + } + if (mIns[i].mType == ASMIT_AND && mIns[i].mMode == ASMIM_IMMEDIATE && mIns[i].mAddress == 0) { mIns[i].mType = ASMIT_LDA;