@@ -550,10 +550,8 @@ struct LoopInterchange {
550
550
// For the old pass manager CacheCost would be null.
551
551
DenseMap<const Loop *, unsigned > CostMap;
552
552
if (CC != nullptr ) {
553
- const auto &LoopCosts = CC->getLoopCosts ();
554
- for (unsigned i = 0 ; i < LoopCosts.size (); i++) {
555
- CostMap[LoopCosts[i].first ] = i;
556
- }
553
+ for (const auto &[Idx, Cost] : enumerate(CC->getLoopCosts ()))
554
+ CostMap[Cost.first ] = Idx;
557
555
}
558
556
// We try to achieve the globally optimal memory access for the loopnest,
559
557
// and do interchange based on a bubble-sort fasion. We start from
@@ -970,8 +968,8 @@ areInnerLoopExitPHIsSupported(Loop *InnerL, Loop *OuterL,
970
968
static bool areOuterLoopExitPHIsSupported (Loop *OuterLoop, Loop *InnerLoop) {
971
969
BasicBlock *LoopNestExit = OuterLoop->getUniqueExitBlock ();
972
970
for (PHINode &PHI : LoopNestExit->phis ()) {
973
- for (unsigned i = 0 ; i < PHI.getNumIncomingValues (); i++ ) {
974
- Instruction *IncomingI = dyn_cast<Instruction>(PHI. getIncomingValue (i) );
971
+ for (Value *Incoming : PHI.incoming_values () ) {
972
+ Instruction *IncomingI = dyn_cast<Instruction>(Incoming );
975
973
if (!IncomingI || IncomingI->getParent () != OuterLoop->getLoopLatch ())
976
974
continue ;
977
975
@@ -1130,15 +1128,14 @@ int LoopInterchangeProfitability::getInstrOrderCost() {
1130
1128
for (BasicBlock *BB : InnerLoop->blocks ()) {
1131
1129
for (Instruction &Ins : *BB) {
1132
1130
if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&Ins)) {
1133
- unsigned NumOp = GEP->getNumOperands ();
1134
1131
bool FoundInnerInduction = false ;
1135
1132
bool FoundOuterInduction = false ;
1136
- for (unsigned i = 0 ; i < NumOp; ++i ) {
1133
+ for (Value *Op : GEP-> operands () ) {
1137
1134
// Skip operands that are not SCEV-able.
1138
- if (!SE->isSCEVable (GEP-> getOperand (i) ->getType ()))
1135
+ if (!SE->isSCEVable (Op ->getType ()))
1139
1136
continue ;
1140
1137
1141
- const SCEV *OperandVal = SE->getSCEV (GEP-> getOperand (i) );
1138
+ const SCEV *OperandVal = SE->getSCEV (Op );
1142
1139
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(OperandVal);
1143
1140
if (!AR)
1144
1141
continue ;
@@ -1218,8 +1215,8 @@ LoopInterchangeProfitability::isProfitablePerInstrOrderCost() {
1218
1215
1219
1216
// / Return true if we can vectorize the loop specified by \p LoopId.
1220
1217
static bool canVectorize (const CharMatrix &DepMatrix, unsigned LoopId) {
1221
- for (unsigned I = 0 ; I != DepMatrix. size (); I++ ) {
1222
- char Dir = DepMatrix[I] [LoopId];
1218
+ for (const auto &Dep : DepMatrix) {
1219
+ char Dir = Dep [LoopId];
1223
1220
if (Dir != ' I' && Dir != ' =' )
1224
1221
return false ;
1225
1222
}
0 commit comments