@@ -1134,21 +1134,24 @@ LoopInterchangeProfitability::isProfitablePerLoopCacheAnalysis(
1134
1134
// This is the new cost model returned from loop cache analysis.
1135
1135
// A smaller index means the loop should be placed an outer loop, and vice
1136
1136
// versa.
1137
- if (CostMap.contains (InnerLoop) && CostMap.contains (OuterLoop)) {
1138
- unsigned InnerIndex = 0 , OuterIndex = 0 ;
1139
- InnerIndex = CostMap.find (InnerLoop)->second ;
1140
- OuterIndex = CostMap.find (OuterLoop)->second ;
1141
- LLVM_DEBUG (dbgs () << " InnerIndex = " << InnerIndex
1142
- << " , OuterIndex = " << OuterIndex << " \n " );
1143
- if (InnerIndex < OuterIndex)
1144
- return std::optional<bool >(true );
1145
- assert (InnerIndex != OuterIndex && " CostMap should assign unique "
1146
- " numbers to each loop" );
1147
- if (CC->getLoopCost (*OuterLoop) == CC->getLoopCost (*InnerLoop))
1148
- return std::nullopt;
1149
- return std::optional<bool >(false );
1150
- }
1151
- return std::nullopt;
1137
+ auto InnerLoopIt = CostMap.find (InnerLoop);
1138
+ if (InnerLoopIt == CostMap.end ())
1139
+ return std::nullopt;
1140
+ auto OuterLoopIt = CostMap.find (OuterLoop);
1141
+ if (OuterLoopIt == CostMap.end ())
1142
+ return std::nullopt;
1143
+
1144
+ unsigned InnerIndex = InnerLoopIt->second ;
1145
+ unsigned OuterIndex = OuterLoopIt->second ;
1146
+ LLVM_DEBUG (dbgs () << " InnerIndex = " << InnerIndex
1147
+ << " , OuterIndex = " << OuterIndex << " \n " );
1148
+ if (InnerIndex < OuterIndex)
1149
+ return std::optional<bool >(true );
1150
+ assert (InnerIndex != OuterIndex && " CostMap should assign unique "
1151
+ " numbers to each loop" );
1152
+ if (CC->getLoopCost (*OuterLoop) == CC->getLoopCost (*InnerLoop))
1153
+ return std::nullopt;
1154
+ return std::optional<bool >(false );
1152
1155
}
1153
1156
1154
1157
std::optional<bool >
0 commit comments