@@ -113,11 +113,14 @@ static cl::list<RuleTy> Profitabilities(
113113 " work with other options)" )));
114114
115115#ifndef NDEBUG
116- static bool noDuplicateRules (ArrayRef<RuleTy> Rules) {
116+ static bool noDuplicateRulesAndIgnore (ArrayRef<RuleTy> Rules) {
117117 SmallSet<RuleTy, 4 > Set;
118- for (RuleTy Rule : Rules)
118+ for (RuleTy Rule : Rules) {
119119 if (!Set.insert (Rule).second )
120120 return false ;
121+ if (Rule == RuleTy::Ignore)
122+ return false ;
123+ }
121124 return true ;
122125}
123126
@@ -1291,9 +1294,11 @@ bool LoopInterchangeProfitability::isProfitable(
12911294 const Loop *InnerLoop, const Loop *OuterLoop, unsigned InnerLoopId,
12921295 unsigned OuterLoopId, CharMatrix &DepMatrix, CacheCostManager &CCM) {
12931296
1294- // Return true if interchange is forced.
1297+ // Return true if interchange is forced and the cost-model ignored .
12951298 if (Profitabilities.size () == 1 && Profitabilities[0 ] == RuleTy::Ignore)
12961299 return true ;
1300+ assert (noDuplicateRulesAndIgnore (Profitabilities) &&
1301+ " Duplicate rules and option 'ignore' are not allowed" );
12971302
12981303 // isProfitable() is structured to avoid endless loop interchange. If the
12991304 // highest priority rule (isProfitablePerLoopCacheAnalysis by default) could
@@ -1303,7 +1308,6 @@ bool LoopInterchangeProfitability::isProfitable(
13031308 // second highest priority rule (isProfitablePerInstrOrderCost by default).
13041309 // Likewise, if it failed to analysis the profitability then only, the last
13051310 // rule (isProfitableForVectorization by default) will decide.
1306- assert (noDuplicateRules (Profitabilities) && " Detect duplicate rules" );
13071311 std::optional<bool > shouldInterchange;
13081312 for (RuleTy RT : Profitabilities) {
13091313 switch (RT) {
@@ -1321,9 +1325,7 @@ bool LoopInterchangeProfitability::isProfitable(
13211325 isProfitableForVectorization (InnerLoopId, OuterLoopId, DepMatrix);
13221326 break ;
13231327 case RuleTy::Ignore:
1324- LLVM_DEBUG (dbgs () << " Interchange profitability: option 'ignore' has no "
1325- " effect in combination with other options\n " ;
1326- dbgs () << " To force interchange, only use 'ignore'" );
1328+ // Nothing to do, this has no effect.
13271329 break ;
13281330 }
13291331
0 commit comments