@@ -78,6 +78,7 @@ enum class RuleTy {
78
78
PerLoopCacheAnalysis,
79
79
PerInstrOrderCost,
80
80
ForVectorization,
81
+ Ignore
81
82
};
82
83
83
84
} // end anonymous namespace
@@ -106,14 +107,20 @@ static cl::list<RuleTy> Profitabilities(
106
107
clEnumValN(RuleTy::PerInstrOrderCost, " instorder" ,
107
108
" Prioritize the IVs order of each instruction" ),
108
109
clEnumValN(RuleTy::ForVectorization, " vectorize" ,
109
- " Prioritize vectorization" )));
110
+ " Prioritize vectorization" ),
111
+ clEnumValN(RuleTy::Ignore, " ignore" ,
112
+ " Ignore profitability, force interchange (does not "
113
+ " work with other options)" )));
110
114
111
115
#ifndef NDEBUG
112
- static bool noDuplicateRules (ArrayRef<RuleTy> Rules) {
116
+ static bool noDuplicateRulesAndIgnore (ArrayRef<RuleTy> Rules) {
113
117
SmallSet<RuleTy, 4 > Set;
114
- for (RuleTy Rule : Rules)
118
+ for (RuleTy Rule : Rules) {
115
119
if (!Set.insert (Rule).second )
116
120
return false ;
121
+ if (Rule == RuleTy::Ignore)
122
+ return false ;
123
+ }
117
124
return true ;
118
125
}
119
126
@@ -1357,6 +1364,13 @@ std::optional<bool> LoopInterchangeProfitability::isProfitableForVectorization(
1357
1364
bool LoopInterchangeProfitability::isProfitable (
1358
1365
const Loop *InnerLoop, const Loop *OuterLoop, unsigned InnerLoopId,
1359
1366
unsigned OuterLoopId, CharMatrix &DepMatrix, CacheCostManager &CCM) {
1367
+
1368
+ // Return true if interchange is forced and the cost-model ignored.
1369
+ if (Profitabilities.size () == 1 && Profitabilities[0 ] == RuleTy::Ignore)
1370
+ return true ;
1371
+ assert (noDuplicateRulesAndIgnore (Profitabilities) &&
1372
+ " Duplicate rules and option 'ignore' are not allowed" );
1373
+
1360
1374
// isProfitable() is structured to avoid endless loop interchange. If the
1361
1375
// highest priority rule (isProfitablePerLoopCacheAnalysis by default) could
1362
1376
// decide the profitability then, profitability check will stop and return the
@@ -1365,7 +1379,6 @@ bool LoopInterchangeProfitability::isProfitable(
1365
1379
// second highest priority rule (isProfitablePerInstrOrderCost by default).
1366
1380
// Likewise, if it failed to analysis the profitability then only, the last
1367
1381
// rule (isProfitableForVectorization by default) will decide.
1368
- assert (noDuplicateRules (Profitabilities) && " Detect duplicate rules" );
1369
1382
std::optional<bool > shouldInterchange;
1370
1383
for (RuleTy RT : Profitabilities) {
1371
1384
switch (RT) {
@@ -1382,6 +1395,9 @@ bool LoopInterchangeProfitability::isProfitable(
1382
1395
shouldInterchange =
1383
1396
isProfitableForVectorization (InnerLoopId, OuterLoopId, DepMatrix);
1384
1397
break ;
1398
+ case RuleTy::Ignore:
1399
+ llvm_unreachable (" Option 'ignore' is not supported with other options" );
1400
+ break ;
1385
1401
}
1386
1402
1387
1403
// If this rule could determine the profitability, don't call subsequent
0 commit comments