diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp index 76cc8f402c5a..8ddd52df4aba 100644 --- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -2247,8 +2247,7 @@ CleanupAndExit: DT->addNewBlock(MemmoveB, Preheader); // Find the new immediate dominator of the exit block. BasicBlock *ExitD = Preheader; - for (auto PI = pred_begin(ExitB), PE = pred_end(ExitB); PI != PE; ++PI) { - BasicBlock *PB = *PI; + for (BasicBlock *PB : predecessors(ExitB)) { ExitD = DT->findNearestCommonDominator(ExitD, PB); if (!ExitD) break; diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 5f14fe48d0e7..5957661eed3f 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -2610,15 +2610,14 @@ ChangeStatus AAExecutionDomainFunction::updateImpl(Attributor &A) { // Merge all the predecessor states into the current basic block. A basic // block is executed by a single thread if all of its predecessors are. auto MergePredecessorStates = [&](BasicBlock *BB) { - if (pred_begin(BB) == pred_end(BB)) + if (pred_empty(BB)) return SingleThreadedBBs.contains(BB); bool IsInitialThread = true; - for (auto PredBB = pred_begin(BB), PredEndBB = pred_end(BB); - PredBB != PredEndBB; ++PredBB) { - if (!IsInitialThreadOnly(dyn_cast((*PredBB)->getTerminator()), + for (BasicBlock *PredBB : predecessors(BB)) { + if (!IsInitialThreadOnly(dyn_cast(PredBB->getTerminator()), BB)) - IsInitialThread &= SingleThreadedBBs.contains(*PredBB); + IsInitialThread &= SingleThreadedBBs.contains(PredBB); } return IsInitialThread; diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index a1fa0e336048..bf714d167670 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -1578,8 +1578,7 @@ static bool canSplitPredecessors(PHINode *PN, LoopSafetyInfo *SafetyInfo) { // predecessor fairly simple. if (!SafetyInfo->getBlockColors().empty() && BB->getFirstNonPHI()->isEHPad()) return false; - for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { - BasicBlock *BBPred = *PI; + for (BasicBlock *BBPred : predecessors(BB)) { if (isa(BBPred->getTerminator()) || isa(BBPred->getTerminator())) return false;