[llvm-branch-commits] [llvm] [DA] Fix overflow in the Exact RDIV test (PR #189578)

Ryotaro Kasuga via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 31 03:02:33 PDT 2026


https://github.com/kasuga-fj created https://github.com/llvm/llvm-project/pull/189578

None

>From 6838172cf2f36ec032b67fcd45e157a82ce3b6af Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Tue, 31 Mar 2026 10:00:53 +0000
Subject: [PATCH] [DA] Fix overflow in the Exact RDIV test

---
 llvm/lib/Analysis/DependenceAnalysis.cpp                    | 4 +++-
 .../DependenceAnalysis/exact-rdiv-delta-overflow.ll         | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 22e486a6d3b7d..94970b60aa512 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -1957,7 +1957,9 @@ bool DependenceInfo::exactRDIVtest(const SCEVAddRecExpr *Src,
   if (!Src->hasNoSignedWrap() || !Dst->hasNoSignedWrap())
     return false;
 
-  const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
+  const SCEV *Delta = minusSCEVNoSignedOverflow(DstConst, SrcConst, *SE);
+  if (!Delta)
+    return false;
   LLVM_DEBUG(dbgs() << "\t    Delta = " << *Delta << "\n");
   const SCEVConstant *ConstDelta = dyn_cast<SCEVConstant>(Delta);
   const SCEVConstant *ConstSrcCoeff = dyn_cast<SCEVConstant>(SrcCoeff);
diff --git a/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-delta-overflow.ll b/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-delta-overflow.ll
index 25b7ccb837709..2570ed98ea4e3 100644
--- a/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-delta-overflow.ll
+++ b/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-delta-overflow.ll
@@ -20,14 +20,14 @@
 ;  A[-6*i + INT64_MAX]     |       | A[3*max_i - 2]         | A[1]
 ;  A[3*i - 2]              | A[1]  |                        | A[3*max_i - 2]
 ;
-; FIXME: There is a dependency between the two stores.
+; There is a dependency between the two stores.
 ;
 define void @exact_rdiv_delta_ovfl(ptr %A) {
 ; CHECK-ALL-LABEL: 'exact_rdiv_delta_ovfl'
 ; CHECK-ALL-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1
 ; CHECK-ALL-NEXT:    da analyze - none!
 ; CHECK-ALL-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
-; CHECK-ALL-NEXT:    da analyze - none!
+; CHECK-ALL-NEXT:    da analyze - output [|<]!
 ; CHECK-ALL-NEXT:  Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
 ; CHECK-ALL-NEXT:    da analyze - none!
 ;
@@ -35,7 +35,7 @@ define void @exact_rdiv_delta_ovfl(ptr %A) {
 ; CHECK-EXACT-RDIV-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1
 ; CHECK-EXACT-RDIV-NEXT:    da analyze - output [*]!
 ; CHECK-EXACT-RDIV-NEXT:  Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
-; CHECK-EXACT-RDIV-NEXT:    da analyze - none!
+; CHECK-EXACT-RDIV-NEXT:    da analyze - output [|<]!
 ; CHECK-EXACT-RDIV-NEXT:  Src: store i8 1, ptr %gep.1, align 1 --> Dst: store i8 1, ptr %gep.1, align 1
 ; CHECK-EXACT-RDIV-NEXT:    da analyze - output [*]!
 ;



More information about the llvm-branch-commits mailing list