From 925ee9d8f3e511e8bc36101054783fe9e1d4547a Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sat, 21 Sep 2024 14:38:35 +0200 Subject: [PATCH] Fix constant pointer if conditions --- oscar64/InterCode.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index 2dbd3da..c2851a7 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -14816,7 +14816,19 @@ InterCodeBasicBlock* InterCodeBasicBlock::CheckIsConstBranch(const GrowingInstru if (k < tins.Size() && tins[k]->mCode == IC_CONSTANT) { - InterCodeBasicBlock* tblock = tins[k]->mConst.mIntConst ? mTrueJump : mFalseJump; + InterInstruction* cins = tins[k]; + + bool istrue = false; + InterType it = cins->mDst.mType; + + if (it == IT_FLOAT) + istrue = cins->mConst.mFloatConst != 0; + else if (it == IT_POINTER) + istrue = cins->mConst.mMemory != IM_ABSOLUTE || cins->mConst.mIntConst != 0; + else + istrue = cins->mConst.mIntConst != 0; + + InterCodeBasicBlock* tblock = istrue ? mTrueJump : mFalseJump; InterCodeBasicBlock* xblock = this->Clone(); InterInstruction* bins = xblock->mInstructions.Pop();