[llvm-branch-commits] [llvm] [DA] Add overflow check in BanerjeeMIVtest (PR #190469)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Apr 4 08:53:19 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Ruoyu Qiu (cabbaken)

<details>
<summary>Changes</summary>

Add an overflow check in BanerjeeMIVtest.
Fix the related test case.



---
Full diff: https://github.com/llvm/llvm-project/pull/190469.diff


2 Files Affected:

- (modified) llvm/lib/Analysis/DependenceAnalysis.cpp (+3-1) 
- (modified) llvm/test/Analysis/DependenceAnalysis/banerjee-overflow.ll (+1-3) 


``````````diff
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index bf70af0682936..62e6b3071e3b4 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -2261,7 +2261,9 @@ bool DependenceInfo::banerjeeMIVtest(const SCEV *Src, const SCEV *Dst,
   const SCEV *B0;
   CoefficientInfo *B = collectCoeffInfo(Dst, false, B0);
   BoundInfo *Bound = new BoundInfo[MaxLevels + 1];
-  const SCEV *Delta = SE->getMinusSCEV(B0, A0);
+  const SCEV *Delta = minusSCEVNoSignedOverflow(B0, A0, *SE);
+  if (!Delta)
+    return false;
   LLVM_DEBUG(dbgs() << "\tDelta = " << *Delta << '\n');
 
   // Compute bounds for all the * directions.
diff --git a/llvm/test/Analysis/DependenceAnalysis/banerjee-overflow.ll b/llvm/test/Analysis/DependenceAnalysis/banerjee-overflow.ll
index 6892a1e49ba9c..368a80fc095e7 100644
--- a/llvm/test/Analysis/DependenceAnalysis/banerjee-overflow.ll
+++ b/llvm/test/Analysis/DependenceAnalysis/banerjee-overflow.ll
@@ -10,8 +10,6 @@
 ;     A[i - j + 9223372036854775805] = 0;
 ;     A[i + j - 5] = 0;
 ;
-; FIXME: DependenceAnalysis fails to detect dependency between two stores.
-;
 ; memory accesses                     | (i,j) == (0,4611686018427387905)
 ; ------------------------------------|----------------------------------
 ; A[i - j + 9223372036854775805]      | A[4611686018427387900]
@@ -22,7 +20,7 @@ define void @banerjee_delta_ovfl(ptr %A) {
 ; CHECK-NEXT:  Src: store i8 0, ptr %arrayidx1, align 8 --> Dst: store i8 0, ptr %arrayidx1, align 8
 ; CHECK-NEXT:    da analyze - output [* *]!
 ; CHECK-NEXT:  Src: store i8 0, ptr %arrayidx1, align 8 --> Dst: store i8 0, ptr %arrayidx2, align 8
-; CHECK-NEXT:    da analyze - none!
+; CHECK-NEXT:    da analyze - output [* *|<]!
 ; CHECK-NEXT:  Src: store i8 0, ptr %arrayidx2, align 8 --> Dst: store i8 0, ptr %arrayidx2, align 8
 ; CHECK-NEXT:    da analyze - output [* *]!
 ;

``````````

</details>


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


More information about the llvm-branch-commits mailing list