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

Ruoyu Qiu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Apr 4 10:26:47 PDT 2026


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

>From d4fe1d33c9886b45678792312eb416fa873fa679 Mon Sep 17 00:00:00 2001
From: Ruoyu Qiu <cabbaken at outlook.com>
Date: Sat, 4 Apr 2026 15:49:13 +0000
Subject: [PATCH] [DA] Add overflow check in BanerjeeMIVtest

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

Signed-off-by: Ruoyu Qiu <cabbaken at outlook.com>
---
 llvm/lib/Analysis/DependenceAnalysis.cpp                  | 8 +++++++-
 .../test/Analysis/DependenceAnalysis/banerjee-overflow.ll | 4 +---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index bf70af0682936..928570a718223 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -2261,7 +2261,13 @@ 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) {
+    delete[] Bound;
+    delete[] A;
+    delete[] B;
+    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 [* *]!
 ;



More information about the llvm-branch-commits mailing list