[llvm] [DA] Require 'nsw' for AddRecs in the WeakCrossing SIV test (PR #185041)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 01:19:49 PDT 2026


================
@@ -1363,15 +1363,19 @@ bool DependenceInfo::strongSIVtest(const SCEVAddRecExpr *Src,
 // Can determine iteration for splitting.
 //
 // Return true if dependence disproved.
-bool DependenceInfo::weakCrossingSIVtest(const SCEV *Coeff,
-                                         const SCEV *SrcConst,
-                                         const SCEV *DstConst,
-                                         const Loop *CurSrcLoop,
-                                         const Loop *CurDstLoop, unsigned Level,
+bool DependenceInfo::weakCrossingSIVtest(const SCEVAddRecExpr *Src,
+                                         const SCEVAddRecExpr *Dst,
+                                         unsigned Level,
                                          FullDependence &Result) const {
   if (!isDependenceTestEnabled(DependenceTestType::WeakCrossingSIV))
     return false;
 
+  if (!Src->hasNoSignedWrap() || !Dst->hasNoSignedWrap())
+    return false;
+
+  const SCEV *Coeff = Src->getStepRecurrence(*SE);
----------------
kasuga-fj wrote:

Maybe better to insert an assertion like `assert(Coeff == SE->getNegativeSCEV(Dst->getStepReccurence(*SE)))`. Also consider to add a comment or assertion for cases where `Coeff` is the signed minimum value.

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


More information about the llvm-commits mailing list