@@ -550,10 +550,8 @@ struct LoopInterchange {
550550 // For the old pass manager CacheCost would be null.
551551 DenseMap<const Loop *, unsigned > CostMap;
552552 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;
557555 }
558556 // We try to achieve the globally optimal memory access for the loopnest,
559557 // and do interchange based on a bubble-sort fasion. We start from
@@ -970,8 +968,8 @@ areInnerLoopExitPHIsSupported(Loop *InnerL, Loop *OuterL,
970968static bool areOuterLoopExitPHIsSupported (Loop *OuterLoop, Loop *InnerLoop) {
971969 BasicBlock *LoopNestExit = OuterLoop->getUniqueExitBlock ();
972970 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 );
975973 if (!IncomingI || IncomingI->getParent () != OuterLoop->getLoopLatch ())
976974 continue ;
977975
@@ -1130,15 +1128,14 @@ int LoopInterchangeProfitability::getInstrOrderCost() {
11301128 for (BasicBlock *BB : InnerLoop->blocks ()) {
11311129 for (Instruction &Ins : *BB) {
11321130 if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&Ins)) {
1133- unsigned NumOp = GEP->getNumOperands ();
11341131 bool FoundInnerInduction = false ;
11351132 bool FoundOuterInduction = false ;
1136- for (unsigned i = 0 ; i < NumOp; ++i ) {
1133+ for (Value *Op : GEP-> operands () ) {
11371134 // Skip operands that are not SCEV-able.
1138- if (!SE->isSCEVable (GEP-> getOperand (i) ->getType ()))
1135+ if (!SE->isSCEVable (Op ->getType ()))
11391136 continue ;
11401137
1141- const SCEV *OperandVal = SE->getSCEV (GEP-> getOperand (i) );
1138+ const SCEV *OperandVal = SE->getSCEV (Op );
11421139 const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(OperandVal);
11431140 if (!AR)
11441141 continue ;
@@ -1218,8 +1215,8 @@ LoopInterchangeProfitability::isProfitablePerInstrOrderCost() {
12181215
12191216// / Return true if we can vectorize the loop specified by \p LoopId.
12201217static 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];
12231220 if (Dir != ' I' && Dir != ' =' )
12241221 return false ;
12251222 }
0 commit comments