[llvm] 9099eef - [SCEV] Use getUnsignedOverflowLimit at a site (NFC) (#217395)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 23 05:22:04 PDT 2026
Author: Ramkumar Ramachandra
Date: 2026-08-23T13:21:59+01:00
New Revision: 9099eef1f55537968796f7fdaf30602cf216e79a
URL: https://github.com/llvm/llvm-project/commit/9099eef1f55537968796f7fdaf30602cf216e79a
DIFF: https://github.com/llvm/llvm-project/commit/9099eef1f55537968796f7fdaf30602cf216e79a.diff
LOG: [SCEV] Use getUnsignedOverflowLimit at a site (NFC) (#217395)
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a05b7e9714f01..2be8495c164fc 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -5214,7 +5214,6 @@ ScalarEvolution::proveNoUnsignedWrapViaInduction(const SCEVAddRecExpr *AR) {
return Result;
const SCEV *Step = AR->getStepRecurrence(*this);
- unsigned BitWidth = getTypeSizeInBits(AR->getType());
const Loop *L = AR->getLoop();
// Check whether the backedge-taken count is SCEVCouldNotCompute.
@@ -5244,14 +5243,13 @@ ScalarEvolution::proveNoUnsignedWrapViaInduction(const SCEVAddRecExpr *AR) {
// start value and the backedge is guarded by a comparison with the post-inc
// value, the addrec is safe.
if (isKnownPositive(Step)) {
- const SCEV *N = getConstant(APInt::getMinValue(BitWidth) -
- getUnsignedRangeMax(Step));
- if (isLoopBackedgeGuardedByCond(L, ICmpInst::ICMP_ULT, AR, N) ||
- isKnownOnEveryIteration(ICmpInst::ICMP_ULT, AR, N)) {
+ ICmpInst::Predicate Pred;
+ const SCEV *OverflowLimit =
+ getUnsignedOverflowLimitForStep(Step, &Pred, this);
+ if (isLoopBackedgeGuardedByCond(L, Pred, AR, OverflowLimit) ||
+ isKnownOnEveryIteration(Pred, AR, OverflowLimit))
Result = setFlags(Result, SCEV::FlagNUW);
- }
}
-
return Result;
}
More information about the llvm-commits
mailing list