[llvm] [SCEV] Bound the max BE count by the range of End - Start. (PR #222752)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 03:21:29 PDT 2026
================
@@ -13378,8 +13364,12 @@ const SCEV *ScalarEvolution::computeMaxBECountForLT(const SCEV *Start,
MaxEnd = IsSigned ? APIntOps::smax(MaxEnd, MinStart)
: APIntOps::umax(MaxEnd, MinStart);
- return getUDivCeilSCEV(getConstant(MaxEnd - MinStart) /* Delta */,
- getConstant(StrideForMaxBECount) /* Step */);
+ APInt Delta = MaxEnd - MinStart;
+
+ // Try to refine Delta in case End - Start gives a tighter bound after
+ Delta = APIntOps::umin(Delta, getUnsignedRangeMax(getMinusSCEV(End, Start)));
----------------
nikic wrote:
Do we need both bits of logic (i.e. the getMinusSCEV result is not always more precise)?
https://github.com/llvm/llvm-project/pull/222752
More information about the llvm-commits
mailing list