[llvm] r257845 - rangify; NFCI (original) (raw)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 16:08:11 PST 2016


Author: spatel Date: Thu Jan 14 18:08:10 2016 New Revision: 257845

URL: http://llvm.org/viewvc/llvm-project?rev=257845&view=rev Log: rangify; NFCI

Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp

Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=257845&r1=257844&r2=257845&view=diff

--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LoopInfo.cpp Thu Jan 14 18:08:10 2016 @@ -92,8 +92,8 @@ bool Loop::makeLoopInvariant(Instruction InsertPt = Preheader->getTerminator(); } // Don't hoist instructions with loop-variant operands. - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (!makeLoopInvariant(I->getOperand(i), Changed, InsertPt)) + for (Value *Operand : I->operands()) + if (!makeLoopInvariant(Operand, Changed, InsertPt)) return false; // Hoist. @@ -146,16 +146,15 @@ PHINode *Loop::getCanonicalInductionVari } bool Loop::isLCSSAForm(DominatorTree &DT) const { - for (block_iterator BI = block_begin(), E = block_end(); BI != E; ++BI) { - BasicBlock *BB = *BI; - for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;++I) { + for (BasicBlock *BB : this->blocks()) { + for (Instruction &I : *BB) { // Tokens can't be used in PHI nodes and live-out tokens prevent loop // optimizations, so for the purposes of considered LCSSA form, we // can ignore them. - if (I->getType()->isTokenTy()) + if (I.getType()->isTokenTy()) continue; - for (Use &U : I->uses()) { + for (Use &U : I.uses()) { Instruction *UI = cast(U.getUser()); BasicBlock *UserBB = UI->getParent(); if (PHINode *P = dyn_cast(UI)) @@ -195,11 +194,11 @@ bool Loop::isLoopSimplifyForm() const { bool Loop::isSafeToClone() const { // Return false if any loop blocks contain indirectbrs, or there are any calls // to noduplicate functions. - for (Loop::block_iterator I = block_begin(), E = block_end(); I != E; ++I) { - if (isa((*I)->getTerminator())) + for (BasicBlock *BB : this->blocks()) { + if (isa(BB->getTerminator())) return false; - if (const InvokeInst *II = dyn_cast((*I)->getTerminator())) { + if (const InvokeInst *II = dyn_cast(BB->getTerminator())) { if (II->cannotDuplicate()) return false; // Return false if any loop blocks contain invokes to EH-pads other than @@ -208,13 +207,12 @@ bool Loop::isSafeToClone() const { if (FirstNonPHI->isEHPad() && !isa(FirstNonPHI)) return false; }

@@ -266,10 +264,10 @@ void Loop::setLoopID(MDNode *LoopID) con } BasicBlock *H = getHeader(); - for (block_iterator I = block_begin(), IE = block_end(); I != IE; ++I) { - TerminatorInst *TI = (*I)->getTerminator(); - for (unsigned i = 0, ie = TI->getNumSuccessors(); i != ie; ++i) { - if (TI->getSuccessor(i) == H) + for (BasicBlock *BB : this->blocks()) { + TerminatorInst *TI = BB->getTerminator(); + for (BasicBlock *Successor : TI->successors()) { + if (Successor == H) TI->setMetadata(LoopMDName, LoopID); } } @@ -286,11 +284,9 @@ bool Loop::isAnnotatedParallel() const { // dependencies (thus converted the loop back to a sequential loop), check // that all the memory instructions in the loop contain parallelism metadata // that point to the same unique "loop id metadata" the loop branch does. - for (block_iterator BB = block_begin(), BE = block_end(); BB != BE; ++BB) { - for (BasicBlock::iterator II = (*BB)->begin(), EE = (*BB)->end(); - II != EE; II++) {

@@ -298,14 +294,14 @@ bool Loop::isAnnotatedParallel() const { // nested parallel loops). The loop identifier metadata refers to // itself so we can check both cases with the same routine. MDNode *loopIdMD = - II->getMetadata(LLVMContext::MD_mem_parallel_loop_access); + I.getMetadata(LLVMContext::MD_mem_parallel_loop_access); if (!loopIdMD) return false; bool loopIdMDFound = false; - for (unsigned i = 0, e = loopIdMD->getNumOperands(); i < e; ++i) { - if (loopIdMD->getOperand(i) == desiredLoopIdMetadata) { + for (const MDOperand &MDOp : loopIdMD->operands()) { + if (MDOp == desiredLoopIdMetadata) { loopIdMDFound = true; break; } @@ -323,10 +319,9 @@ bool Loop::hasDedicatedExits() const { // within the loop. SmallVector<BasicBlock *, 4> ExitBlocks; getExitBlocks(ExitBlocks); - for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) - for (pred_iterator PI = pred_begin(ExitBlocks[i]), - PE = pred_end(ExitBlocks[i]); PI != PE; ++PI) - if (!contains(*PI)) + for (BasicBlock *BB : ExitBlocks) + for (BasicBlock *Predecessor : predecessors(BB)) + if (!contains(Predecessor)) return false; // All the requirements are met. return true; @@ -338,42 +333,38 @@ Loop::getUniqueExitBlocks(SmallVectorImp "getUniqueExitBlocks assumes the loop has canonical form exits!"); SmallVector<BasicBlock *, 32> switchExitBlocks;



More information about the llvm-commits mailing list