[llvm] [DA] use NSW arithmetic (PR #116632)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 02:30:48 PST 2025


================
@@ -3116,11 +3116,9 @@ const SCEV *DependenceInfo::addToCoefficient(const SCEV *Expr,
                                              const Loop *TargetLoop,
                                              const SCEV *Value) const {
   const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Expr);
-  if (!AddRec) // create a new addRec
-    return SE->getAddRecExpr(Expr,
-                             Value,
-                             TargetLoop,
-                             SCEV::FlagAnyWrap); // Worst case, with no info.
+  if (!AddRec)
+    return SE->getAddRecExpr(Expr, Value, TargetLoop, SCEV::FlagNSW);
----------------
Meinersbur wrote:

`if (!AddRec->getNoWrapFlags())` passes for any wrap flag, including `NW` and `NUW`, not necessarily `NSW`. So this might re-interpret an unsigned integer as a signed one?

The latest push doesn't even unclude setting `SCEV::FlagNSW` anymore. Intended?

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


More information about the llvm-commits mailing list