[llvm] [DA] Refactor the signature of the Exact SIV test (NFCI) (PR #186386)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 13 06:25:04 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Ryotaro Kasuga (kasuga-fj)
<details>
<summary>Changes</summary>
Change the signature of `exactSIVtest` to directly pass addrecs instead of passing their operands separately. I *think* this change is not mandatory, but it will simplify the code, especially because we will be checking the presence of nsw flags on the addrecs.
---
Full diff: https://github.com/llvm/llvm-project/pull/186386.diff
2 Files Affected:
- (modified) llvm/include/llvm/Analysis/DependenceAnalysis.h (+1-3)
- (modified) llvm/lib/Analysis/DependenceAnalysis.cpp (+8-7)
``````````diff
diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index 26589571a65e28..cab98726520733 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -541,9 +541,7 @@ class DependenceInfo {
/// Returns true if any possible dependence is disproved.
/// If there might be a dependence, returns false.
/// Sets appropriate direction entry.
- bool exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
- const SCEV *SrcConst, const SCEV *DstConst,
- const Loop *CurrentSrcLoop, const Loop *CurrentDstLoop,
+ bool exactSIVtest(const SCEVAddRecExpr *Src, const SCEVAddRecExpr *Dst,
unsigned Level, FullDependence &Result) const;
/// weakZeroSrcSIVtest - Tests the weak-zero SIV subscript pair
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index c7aefb20354344..13f560f2958bc3 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -1629,14 +1629,16 @@ inferDomainOfAffine(OverflowSafeSignedAPInt A, OverflowSafeSignedAPInt B,
// This is a modified version of the original Banerjee algorithm. The original
// only tested whether Dst depends on Src. This algorithm extends that and
// returns all the dependencies that exist between Dst and Src.
-bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
- const SCEV *SrcConst, const SCEV *DstConst,
- const Loop *CurSrcLoop,
- const Loop *CurDstLoop, unsigned Level,
+bool DependenceInfo::exactSIVtest(const SCEVAddRecExpr *Src,
+ const SCEVAddRecExpr *Dst, unsigned Level,
FullDependence &Result) const {
if (!isDependenceTestEnabled(DependenceTestType::ExactSIV))
return false;
+ const SCEV *SrcCoeff = Src->getStepRecurrence(*SE);
+ const SCEV *SrcConst = Src->getStart();
+ const SCEV *DstCoeff = Dst->getStepRecurrence(*SE);
+ const SCEV *DstConst = Dst->getStart();
LLVM_DEBUG(dbgs() << "\tExact SIV test\n");
LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n");
LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n");
@@ -1674,7 +1676,7 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
std::optional<APInt> UM;
// UM is perhaps unavailable, let's check
if (const SCEVConstant *CUB =
- collectConstantUpperBound(CurSrcLoop, Delta->getType())) {
+ collectConstantUpperBound(Src->getLoop(), Delta->getType())) {
UM = CUB->getAPInt();
LLVM_DEBUG(dbgs() << "\t UM = " << *UM << "\n");
}
@@ -2298,8 +2300,7 @@ bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level,
disproven = weakCrossingSIVtest(SrcCoeff, SrcConst, DstConst, CurSrcLoop,
CurDstLoop, Level, Result);
else
- disproven = exactSIVtest(SrcCoeff, DstCoeff, SrcConst, DstConst,
- CurSrcLoop, CurDstLoop, Level, Result);
+ disproven = exactSIVtest(SrcAddRec, DstAddRec, Level, Result);
return disproven || gcdMIVtest(Src, Dst, Result) ||
symbolicRDIVtest(SrcCoeff, DstCoeff, SrcConst, DstConst, CurSrcLoop,
CurDstLoop);
``````````
</details>
https://github.com/llvm/llvm-project/pull/186386
More information about the llvm-commits
mailing list