[llvm] [SCEV] Use a predicate in howManyLessThans() to prove overflow (PR #208581)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 00:37:05 PDT 2026


================
@@ -13519,23 +13540,26 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
   //      before any possible exit.
   // Note that we have not yet proved RHS invariant (in general).
 
-  const SCEV *Start = IV->getStart();
+  // RHS has been normalized to an integer type above (converted from a
+  // pointer type via getPtrToAddrExpr, if it started out as one), so
+  // RHS->getType() is guaranteed to be an integer type here. Combined with
+  // getConstant(Limit) also producing an integer type of the same BitWidth,
+  // this ensures RHS and getConstant(Limit) have identical LLVM types, as
+  // SCEVComparePredicate requires.
----------------
fhahn wrote:

this seems unnecessarily verbose. better explain what predicate is added and why (compactly), instead of focusing on the type aspect

https://github.com/llvm/llvm-project/pull/208581


More information about the llvm-commits mailing list