[llvm] r237284 - [LoopIdiomRecognize] Use auto + range-based loop. NFC intended.

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed May 13 21:10:23 PDT 2015


> On 2015 May 13, at 12:51, Davide Italiano <davide at freebsd.org> wrote:
> 
> Author: davide
> Date: Wed May 13 14:51:21 2015
> New Revision: 237284
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=237284&view=rev
> Log:
> [LoopIdiomRecognize] Use auto + range-based loop. NFC intended.
> 
> 
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=237284&r1=237283&r2=237284&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Wed May 13 14:51:21 2015
> @@ -639,13 +639,12 @@ bool LoopIdiomRecognize::runOnCountableL
> 
>   bool MadeChange = false;
>   // Scan all the blocks in the loop that are not in subloops.
> -  for (Loop::block_iterator BI = CurLoop->block_begin(),
> -         E = CurLoop->block_end(); BI != E; ++BI) {
> +  for (auto BB : CurLoop->getBlocks()) {

At a quick glance this looks like a copy, since it's not obvious
that we're iterating through pointers.  Please either use:

    for (BasicBlock *BB : ...)

or

    for (auto *BB : ...)



>     // Ignore blocks in subloops.
> -    if (LI.getLoopFor(*BI) != CurLoop)
> +    if (LI.getLoopFor(BB) != CurLoop)
>       continue;
> 
> -    MadeChange |= runOnLoopBlock(*BI, BECount, ExitBlocks);
> +    MadeChange |= runOnLoopBlock(BB, BECount, ExitBlocks);
>   }
>   return MadeChange;
> }
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list