From d6362a305fe9a1a9b5c6c904f8551d5a89f77c55 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Fri, 3 Jan 2025 14:29:08 +0100 Subject: [PATCH] Improve const bitmask optimization --- include/opp/boundint.h | 7 +++++++ oscar64/InterCode.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/opp/boundint.h b/include/opp/boundint.h index d6076a5..4f9f5bd 100644 --- a/include/opp/boundint.h +++ b/include/opp/boundint.h @@ -32,6 +32,13 @@ namespace opp { v = k; } + void operator+=(int k) + { + k += v; + __assume(k >= tmin && k <= tmax); + v = k; + } + operator int() const { int k = v; diff --git a/oscar64/InterCode.cpp b/oscar64/InterCode.cpp index f9836b3..d0d3230 100644 --- a/oscar64/InterCode.cpp +++ b/oscar64/InterCode.cpp @@ -8775,7 +8775,7 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSetsForward(const GrowingVariab { vr.mMinState = IntegerValueRange::S_BOUND; vr.mMinValue = 0; - vr.LimitMax(ins->mSrc[0].mIntConst); + vr.LimitMax(ins->mSrc[0].mIntConst & BuildLowerBitsMask(ins->mSrc[1].mRange.mMaxValue)); } else { @@ -8794,7 +8794,7 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSetsForward(const GrowingVariab { vr.mMinState = IntegerValueRange::S_BOUND; vr.mMinValue = 0; - vr.LimitMax(ins->mSrc[1].mIntConst); + vr.LimitMax(ins->mSrc[1].mIntConst & BuildLowerBitsMask(ins->mSrc[0].mRange.mMaxValue)); } else {