[llvm] 8677f49 - [DA] Refactor the signature of the Weak Zero SIV tests (NFC) (#185825)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 06:11:13 PDT 2026
Author: Ryotaro Kasuga
Date: 2026-03-12T13:11:08Z
New Revision: 8677f491471d44faff257710ec1ea6d67b347bee
URL: https://github.com/llvm/llvm-project/commit/8677f491471d44faff257710ec1ea6d67b347bee
DIFF: https://github.com/llvm/llvm-project/commit/8677f491471d44faff257710ec1ea6d67b347bee.diff
LOG: [DA] Refactor the signature of the Weak Zero SIV tests (NFC) (#185825)
Change the signatures of the Weak Zero SIV tests, specifically by
passing an addrec directly instead of separating it into the coefficient
and constant. This form is more useful to address the several
correctness issues in those tests.
Added:
Modified:
llvm/include/llvm/Analysis/DependenceAnalysis.h
llvm/lib/Analysis/DependenceAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index 6348f7a459c7b..26589571a65e2 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -554,10 +554,8 @@ class DependenceInfo {
/// Returns true if any possible dependence is disproved.
/// If there might be a dependence, returns false.
/// Sets appropriate direction entry.
- bool weakZeroSrcSIVtest(const SCEV *DstCoeff, const SCEV *SrcConst,
- const SCEV *DstConst, const Loop *CurrentSrcLoop,
- const Loop *CurrentDstLoop, unsigned Level,
- FullDependence &Result) const;
+ bool weakZeroSrcSIVtest(const SCEV *SrcConst, const SCEVAddRecExpr *Dst,
+ unsigned Level, FullDependence &Result) const;
/// weakZeroDstSIVtest - Tests the weak-zero SIV subscript pair
/// (Src and Dst) for dependence.
@@ -567,10 +565,8 @@ class DependenceInfo {
/// Returns true if any possible dependence is disproved.
/// If there might be a dependence, returns false.
/// Sets appropriate direction entry.
- bool weakZeroDstSIVtest(const SCEV *SrcCoeff, const SCEV *SrcConst,
- const SCEV *DstConst, const Loop *CurrentSrcLoop,
- const Loop *CurrentDstLoop, unsigned Level,
- FullDependence &Result) const;
+ bool weakZeroDstSIVtest(const SCEVAddRecExpr *Src, const SCEV *DstConst,
+ unsigned Level, FullDependence &Result) const;
/// exactRDIVtest - Tests the RDIV subscript pair for dependence.
/// Things of the form [c1 + a*i] and [c2 + b*j],
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 927f34ec83bb1..c7aefb2035434 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -1813,11 +1813,9 @@ static bool isRemainderZero(const SCEVConstant *Dividend,
// (see also weakZeroDstSIVtest)
//
// Return true if dependence disproved.
-bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
- const SCEV *SrcConst,
- const SCEV *DstConst,
- const Loop *CurSrcLoop,
- const Loop *CurDstLoop, unsigned Level,
+bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *SrcConst,
+ const SCEVAddRecExpr *Dst,
+ unsigned Level,
FullDependence &Result) const {
if (!isDependenceTestEnabled(DependenceTestType::WeakZeroSIV))
return false;
@@ -1825,6 +1823,8 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
// For the WeakSIV test, it's possible the loop isn't common to
// the Src and Dst loops. If it isn't, then there's no need to
// record a direction.
+ const SCEV *DstCoeff = Dst->getStepRecurrence(*SE);
+ const SCEV *DstConst = Dst->getStart();
LLVM_DEBUG(dbgs() << "\tWeak-Zero (src) SIV test\n");
LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << "\n");
LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n");
@@ -1858,7 +1858,7 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
// check that Delta/SrcCoeff < iteration count
// really check NewDelta < count*AbsCoeff
if (const SCEV *UpperBound =
- collectUpperBound(CurSrcLoop, Delta->getType())) {
+ collectUpperBound(Dst->getLoop(), Delta->getType())) {
LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n");
const SCEV *Product = SE->getMulExpr(AbsCoeff, UpperBound);
if (SE->isKnownPredicate(CmpInst::ICMP_SGT, NewDelta, Product)) {
@@ -1924,17 +1924,16 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
// (see also weakZeroSrcSIVtest)
//
// Return true if dependence disproved.
-bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff,
- const SCEV *SrcConst,
- const SCEV *DstConst,
- const Loop *CurSrcLoop,
- const Loop *CurDstLoop, unsigned Level,
+bool DependenceInfo::weakZeroDstSIVtest(const SCEVAddRecExpr *Src,
+ const SCEV *DstConst, unsigned Level,
FullDependence &Result) const {
if (!isDependenceTestEnabled(DependenceTestType::WeakZeroSIV))
return false;
// For the WeakSIV test, it's possible the loop isn't common to the
// Src and Dst loops. If it isn't, then there's no need to record a direction.
+ const SCEV *SrcCoeff = Src->getStepRecurrence(*SE);
+ const SCEV *SrcConst = Src->getStart();
LLVM_DEBUG(dbgs() << "\tWeak-Zero (dst) SIV test\n");
LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << "\n");
LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n");
@@ -1968,7 +1967,7 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff,
// check that Delta/SrcCoeff < iteration count
// really check NewDelta < count*AbsCoeff
if (const SCEV *UpperBound =
- collectUpperBound(CurSrcLoop, Delta->getType())) {
+ collectUpperBound(Src->getLoop(), Delta->getType())) {
LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound << "\n");
const SCEV *Product = SE->getMulExpr(AbsCoeff, UpperBound);
if (SE->isKnownPredicate(CmpInst::ICMP_SGT, NewDelta, Product)) {
@@ -2306,23 +2305,15 @@ bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level,
CurDstLoop);
}
if (SrcAddRec) {
- const SCEV *SrcConst = SrcAddRec->getStart();
- const SCEV *SrcCoeff = SrcAddRec->getStepRecurrence(*SE);
- const SCEV *DstConst = Dst;
const Loop *CurSrcLoop = SrcAddRec->getLoop();
Level = mapSrcLoop(CurSrcLoop);
- return weakZeroDstSIVtest(SrcCoeff, SrcConst, DstConst, CurSrcLoop,
- CurSrcLoop, Level, Result) ||
+ return weakZeroDstSIVtest(SrcAddRec, Dst, Level, Result) ||
gcdMIVtest(Src, Dst, Result);
}
if (DstAddRec) {
- const SCEV *DstConst = DstAddRec->getStart();
- const SCEV *DstCoeff = DstAddRec->getStepRecurrence(*SE);
- const SCEV *SrcConst = Src;
const Loop *CurDstLoop = DstAddRec->getLoop();
Level = mapDstLoop(CurDstLoop);
- return weakZeroSrcSIVtest(DstCoeff, SrcConst, DstConst, CurDstLoop,
- CurDstLoop, Level, Result) ||
+ return weakZeroSrcSIVtest(Src, DstAddRec, Level, Result) ||
gcdMIVtest(Src, Dst, Result);
}
llvm_unreachable("SIV test expected at least one AddRec");
More information about the llvm-commits
mailing list