[llvm] [DependenceAnalysis] Fix incorrect analysis of wrapping AddRec expressions (PR #154982)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 23 01:36:04 PDT 2025


================
@@ -6439,8 +6439,129 @@ void ScalarEvolution::setNoWrapFlags(SCEVAddRecExpr *AddRec,
   }
 }
 
-ConstantRange ScalarEvolution::
-getRangeForUnknownRecurrence(const SCEVUnknown *U) {
+std::optional<bool>
+ScalarEvolution::mayAddRecWrap(const SCEVAddRecExpr *AddRec) {
+  Type *Ty = AddRec->getType();
+
+  // Pointer AddRec expressions do not wrap in the arithmetic sense.
+  if (Ty->isPointerTy())
+    return false;
----------------
nikic wrote:

This doesn't look right. Wrapping on pointers is just wrapping on the address of the pointer.

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


More information about the llvm-commits mailing list