Index: lib/Transforms/Scalar/LoopRotation.cpp =================================================================== --- lib/Transforms/Scalar/LoopRotation.cpp +++ lib/Transforms/Scalar/LoopRotation.cpp @@ -571,10 +571,9 @@ /// Rotate \c L as many times as possible. Return true if the loop is rotated /// at least once. -static bool iterativelyRotateLoop(Loop *L, unsigned MaxHeaderSize, LoopInfo *LI, - const TargetTransformInfo *TTI, - AssumptionCache *AC, DominatorTree *DT, - ScalarEvolution *SE) { +static bool processLoop(Loop *L, unsigned MaxHeaderSize, LoopInfo *LI, + const TargetTransformInfo *TTI, AssumptionCache *AC, + DominatorTree *DT, ScalarEvolution *SE) { // Save the loop metadata. MDNode *LoopMD = L->getLoopID(); @@ -584,11 +583,8 @@ bool SimplifiedLatch = simplifyLoopLatch(L, LI, DT); // One loop can be rotated multiple times. - bool MadeChange = false; - while (rotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE, SimplifiedLatch)) { - MadeChange = true; - SimplifiedLatch = false; - } + bool MadeChange = + rotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE, SimplifiedLatch); // Restore the loop metadata. // NB! We presume LoopRotation DOESN'T ADD its own metadata. @@ -613,7 +609,7 @@ auto *DT = FAM.getCachedResult(*F); auto *SE = FAM.getCachedResult(*F); - bool Changed = iterativelyRotateLoop(&L, MaxHeaderSize, LI, TTI, AC, DT, SE); + bool Changed = processLoop(&L, MaxHeaderSize, LI, TTI, AC, DT, SE); if (!Changed) return PreservedAnalyses::all(); return getLoopPassPreservedAnalyses(); @@ -654,7 +650,7 @@ auto *SEWP = getAnalysisIfAvailable(); auto *SE = SEWP ? &SEWP->getSE() : nullptr; - return iterativelyRotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE); + return processLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE); } }; }