[llvm] r255077 - [IndVars] Use any_of and foreach instead of explicit for loops; NFC
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 18:58:36 PST 2015
On 12/08/2015 03:52 PM, Sanjoy Das via llvm-commits wrote:
> Author: sanjoy
> Date: Tue Dec 8 17:52:58 2015
> New Revision: 255077
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255077&view=rev
> Log:
> [IndVars] Use any_of and foreach instead of explicit for loops; NFC
>
> Modified:
> llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=255077&r1=255076&r2=255077&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Dec 8 17:52:58 2015
> @@ -759,14 +759,9 @@ bool IndVarSimplify::canLoopBeDeleted(
> ++BI;
> }
>
> - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end();
> - LI != LE; ++LI) {
> - for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); BI != BE;
> - ++BI) {
> - if (BI->mayHaveSideEffects())
> - return false;
> - }
> - }
> + for (auto *BB : L->blocks())
> + if (any_of(*BB, [](Instruction &I) { return I.mayHaveSideEffects(); }))
> + return false;
Wouldn't this be clearer as:
for (Instruction &I : instructions(L)) { ... }
Not sure we currently have a instructions range iterator which takes a
Loop, but that might be worth adding if not.
>
> return true;
> }
> @@ -1675,10 +1670,10 @@ static bool hasConcreteDefImpl(Value *V,
> return false;
>
> // Optimistically handle other instructions.
> - for (User::op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) {
> - if (!Visited.insert(*OI).second)
> + for (Value *Op : I->operands()) {
> + if (!Visited.insert(Op).second)
> continue;
> - if (!hasConcreteDefImpl(*OI, Visited, Depth+1))
> + if (!hasConcreteDefImpl(Op, Visited, Depth+1))
> return false;
> }
> return true;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list