[llvm] [DA] Fix symbolic RDIV and Strong SIV with impossible assumptions (PR149501) (PR #157761)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 10 01:45:27 PDT 2025


================
@@ -1243,16 +1243,76 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
   if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) {
     LLVM_DEBUG(dbgs() << "\t    UpperBound = " << *UpperBound);
     LLVM_DEBUG(dbgs() << ", " << *UpperBound->getType() << "\n");
+
+    // Handle negative upper bound - loop doesn't execute.
+    if (SE->isKnownNegative(UpperBound)) {
+      LLVM_DEBUG(dbgs() << "\t    Negative upper bound - no dependence\n");
+      ++StrongSIVindependence;
+      ++StrongSIVsuccesses;
+      return true;
+    }
----------------
kasuga-fj wrote:

(I haven't looked at the other parts, but) I think this is incorrect. In general, `UpperBound` is an unsigned value, may be interpreted as negative in a signed sense. That is, `isKnownNegative(UpperBound)` does not mean that the loop will not be executed.

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


More information about the llvm-commits mailing list