Skip to content

Commit 28cfe72

Browse files
kasuga-fjaokblast
authored andcommitted
[DA] Add option to enable specific dependence test only (llvm#164245)
PR llvm#157084 added an option `da-run-siv-routines-only` to run only SIV routines in DA. This PR replaces that option with a more fine-grained one that allows to select other than SIV routines as well. This option is useful for regression testing of individual DA routines. This patch also reorganizes regression tests that use `da-run-siv-routines-only`.
1 parent f392554 commit 28cfe72

File tree

4 files changed

+980
-327
lines changed

4 files changed

+980
-327
lines changed

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,49 @@ static cl::opt<unsigned> MIVMaxLevelThreshold(
122122
cl::desc("Maximum depth allowed for the recursive algorithm used to "
123123
"explore MIV direction vectors."));
124124

125-
static cl::opt<bool> RunSIVRoutinesOnly(
126-
"da-run-siv-routines-only", cl::init(false), cl::ReallyHidden,
127-
cl::desc("Run only SIV routines and disable others (ZIV, RDIV, and MIV). "
128-
"The purpose is mainly to exclude the influence of those routines "
129-
"in regression tests for SIV routines."));
125+
namespace {
126+
127+
/// Types of dependence test routines.
128+
enum class DependenceTestType {
129+
All,
130+
StrongSIV,
131+
WeakCrossingSIV,
132+
ExactSIV,
133+
WeakZeroSIV,
134+
ExactRDIV,
135+
SymbolicRDIV,
136+
GCDMIV,
137+
BanerjeeMIV,
138+
};
139+
140+
} // anonymous namespace
141+
142+
static cl::opt<DependenceTestType> EnableDependenceTest(
143+
"da-enable-dependence-test", cl::init(DependenceTestType::All),
144+
cl::ReallyHidden,
145+
cl::desc("Run only specified dependence test routine and disable others. "
146+
"The purpose is mainly to exclude the influence of other "
147+
"dependence test routines in regression tests. If set to All, all "
148+
"dependence test routines are enabled."),
149+
cl::values(clEnumValN(DependenceTestType::All, "all",
150+
"Enable all dependence test routines."),
151+
clEnumValN(DependenceTestType::StrongSIV, "strong-siv",
152+
"Enable only Strong SIV test."),
153+
clEnumValN(DependenceTestType::WeakCrossingSIV,
154+
"weak-crossing-siv",
155+
"Enable only Weak-Crossing SIV test."),
156+
clEnumValN(DependenceTestType::ExactSIV, "exact-siv",
157+
"Enable only Exact SIV test."),
158+
clEnumValN(DependenceTestType::WeakZeroSIV, "weak-zero-siv",
159+
"Enable only Weak-Zero SIV test."),
160+
clEnumValN(DependenceTestType::ExactRDIV, "exact-rdiv",
161+
"Enable only Exact RDIV test."),
162+
clEnumValN(DependenceTestType::SymbolicRDIV, "symbolic-rdiv",
163+
"Enable only Symbolic RDIV test."),
164+
clEnumValN(DependenceTestType::GCDMIV, "gcd-miv",
165+
"Enable only GCD MIV test."),
166+
clEnumValN(DependenceTestType::BanerjeeMIV, "banerjee-miv",
167+
"Enable only Banerjee MIV test.")));
130168

131169
// TODO: This flag is disabled by default because it is still under development.
132170
// Enable it or delete this flag when the feature is ready.
@@ -1544,6 +1582,13 @@ static const SCEV *minusSCEVNoSignedOverflow(const SCEV *A, const SCEV *B,
15441582
return nullptr;
15451583
}
15461584

1585+
/// Returns true iff \p Test is enabled.
1586+
static bool isDependenceTestEnabled(DependenceTestType Test) {
1587+
if (EnableDependenceTest == DependenceTestType::All)
1588+
return true;
1589+
return EnableDependenceTest == Test;
1590+
}
1591+
15471592
// testZIV -
15481593
// When we have a pair of subscripts of the form [c1] and [c2],
15491594
// where c1 and c2 are both loop invariant, we attack it using
@@ -1605,6 +1650,9 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
16051650
const Loop *CurDstLoop, unsigned Level,
16061651
FullDependence &Result,
16071652
Constraint &NewConstraint) const {
1653+
if (!isDependenceTestEnabled(DependenceTestType::StrongSIV))
1654+
return false;
1655+
16081656
LLVM_DEBUG(dbgs() << "\tStrong SIV test\n");
16091657
LLVM_DEBUG(dbgs() << "\t Coeff = " << *Coeff);
16101658
LLVM_DEBUG(dbgs() << ", " << *Coeff->getType() << "\n");
@@ -1739,6 +1787,9 @@ bool DependenceInfo::weakCrossingSIVtest(
17391787
const Loop *CurSrcLoop, const Loop *CurDstLoop, unsigned Level,
17401788
FullDependence &Result, Constraint &NewConstraint,
17411789
const SCEV *&SplitIter) const {
1790+
if (!isDependenceTestEnabled(DependenceTestType::WeakCrossingSIV))
1791+
return false;
1792+
17421793
LLVM_DEBUG(dbgs() << "\tWeak-Crossing SIV test\n");
17431794
LLVM_DEBUG(dbgs() << "\t Coeff = " << *Coeff << "\n");
17441795
LLVM_DEBUG(dbgs() << "\t SrcConst = " << *SrcConst << "\n");
@@ -1997,6 +2048,9 @@ bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
19972048
const Loop *CurDstLoop, unsigned Level,
19982049
FullDependence &Result,
19992050
Constraint &NewConstraint) const {
2051+
if (!isDependenceTestEnabled(DependenceTestType::ExactSIV))
2052+
return false;
2053+
20002054
LLVM_DEBUG(dbgs() << "\tExact SIV test\n");
20012055
LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n");
20022056
LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n");
@@ -2176,6 +2230,9 @@ bool DependenceInfo::weakZeroSrcSIVtest(
21762230
const SCEV *DstCoeff, const SCEV *SrcConst, const SCEV *DstConst,
21772231
const Loop *CurSrcLoop, const Loop *CurDstLoop, unsigned Level,
21782232
FullDependence &Result, Constraint &NewConstraint) const {
2233+
if (!isDependenceTestEnabled(DependenceTestType::WeakZeroSIV))
2234+
return false;
2235+
21792236
// For the WeakSIV test, it's possible the loop isn't common to
21802237
// the Src and Dst loops. If it isn't, then there's no need to
21812238
// record a direction.
@@ -2284,6 +2341,9 @@ bool DependenceInfo::weakZeroDstSIVtest(
22842341
const SCEV *SrcCoeff, const SCEV *SrcConst, const SCEV *DstConst,
22852342
const Loop *CurSrcLoop, const Loop *CurDstLoop, unsigned Level,
22862343
FullDependence &Result, Constraint &NewConstraint) const {
2344+
if (!isDependenceTestEnabled(DependenceTestType::WeakZeroSIV))
2345+
return false;
2346+
22872347
// For the WeakSIV test, it's possible the loop isn't common to the
22882348
// Src and Dst loops. If it isn't, then there's no need to record a direction.
22892349
LLVM_DEBUG(dbgs() << "\tWeak-Zero (dst) SIV test\n");
@@ -2367,8 +2427,9 @@ bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
23672427
const SCEV *SrcConst, const SCEV *DstConst,
23682428
const Loop *SrcLoop, const Loop *DstLoop,
23692429
FullDependence &Result) const {
2370-
if (RunSIVRoutinesOnly)
2430+
if (!isDependenceTestEnabled(DependenceTestType::ExactRDIV))
23712431
return false;
2432+
23722433
LLVM_DEBUG(dbgs() << "\tExact RDIV test\n");
23732434
LLVM_DEBUG(dbgs() << "\t SrcCoeff = " << *SrcCoeff << " = AM\n");
23742435
LLVM_DEBUG(dbgs() << "\t DstCoeff = " << *DstCoeff << " = BM\n");
@@ -2513,8 +2574,9 @@ bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
25132574
const SCEV *C1, const SCEV *C2,
25142575
const Loop *Loop1,
25152576
const Loop *Loop2) const {
2516-
if (RunSIVRoutinesOnly)
2577+
if (!isDependenceTestEnabled(DependenceTestType::SymbolicRDIV))
25172578
return false;
2579+
25182580
++SymbolicRDIVapplications;
25192581
LLVM_DEBUG(dbgs() << "\ttry symbolic RDIV test\n");
25202582
LLVM_DEBUG(dbgs() << "\t A1 = " << *A1);
@@ -2828,8 +2890,9 @@ bool DependenceInfo::accumulateCoefficientsGCD(const SCEV *Expr,
28282890
// to "a common divisor".
28292891
bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
28302892
FullDependence &Result) const {
2831-
if (RunSIVRoutinesOnly)
2893+
if (!isDependenceTestEnabled(DependenceTestType::GCDMIV))
28322894
return false;
2895+
28332896
LLVM_DEBUG(dbgs() << "starting gcd\n");
28342897
++GCDapplications;
28352898
unsigned BitWidth = SE->getTypeSizeInBits(Src->getType());
@@ -2996,8 +3059,9 @@ bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
29963059
bool DependenceInfo::banerjeeMIVtest(const SCEV *Src, const SCEV *Dst,
29973060
const SmallBitVector &Loops,
29983061
FullDependence &Result) const {
2999-
if (RunSIVRoutinesOnly)
3062+
if (!isDependenceTestEnabled(DependenceTestType::BanerjeeMIV))
30003063
return false;
3064+
30013065
LLVM_DEBUG(dbgs() << "starting Banerjee\n");
30023066
++BanerjeeApplications;
30033067
LLVM_DEBUG(dbgs() << " Src = " << *Src << '\n');

0 commit comments

Comments
 (0)