[llvm-branch-commits] [llvm] [DA] Check nsw flags for addrecs in the Exact RDIV test (PR #189536)
Ruoyu Qiu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Mar 30 22:47:48 PDT 2026
https://github.com/cabbaken created https://github.com/llvm/llvm-project/pull/189536
This patch adds a check to ensure that the addrecs have nsw flags at the
beginning of the Exact SIV test. If either of them doesn't have, the
analysis bails out. This check is necessary because the subsequent
process in the Exact SIV test assumes that they don't wrap.
>From f35231b232a1f6c4c7a4063e5dbbdd9e51dc649c Mon Sep 17 00:00:00 2001
From: Ruoyu Qiu <cabbaken at outlook.com>
Date: Tue, 31 Mar 2026 05:30:15 +0000
Subject: [PATCH] [DA] Check nsw flags for addrecs in the Exact RDIV test
This patch adds a check to ensure that the addrecs have nsw flags at the
beginning of the Exact SIV test. If either of them doesn't have, the
analysis bails out. This check is necessary because the subsequent
process in the Exact SIV test assumes that they don't wrap.
---
llvm/lib/Analysis/DependenceAnalysis.cpp | 4 ++++
.../Analysis/DependenceAnalysis/exact-rdiv-addrec-wrap.ll | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index d9dc6beeca284..4e32de824d3ac 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -1961,6 +1961,10 @@ bool DependenceInfo::exactRDIVtest(const SCEVAddRecExpr *Src,
LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n");
LLVM_DEBUG(dbgs() << "\t DstConst = " << *DstConst << "\n");
++ExactRDIVapplications;
+
+ if (!Src->hasNoSignedWrap() || !Dst->hasNoSignedWrap())
+ return false;
+
const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
LLVM_DEBUG(dbgs() << "\t Delta = " << *Delta << "\n");
const SCEVConstant *ConstDelta = dyn_cast<SCEVConstant>(Delta);
diff --git a/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-addrec-wrap.ll b/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-addrec-wrap.ll
index 0fccef544d2ac..5805d19d01bbe 100644
--- a/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-addrec-wrap.ll
+++ b/llvm/test/Analysis/DependenceAnalysis/exact-rdiv-addrec-wrap.ll
@@ -38,7 +38,7 @@ define void @exact_rdiv_no_nsw(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