From 6d953d691713e1bf8c30db5b93ede949c75fa772 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Sun, 18 Oct 2015 00:29:23 +0000 Subject: [PATCH] [SCEV] Use std::all_of and std::any_of; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250635 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolution.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 6c72feb71cd..6b32a7a9d29 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2844,12 +2844,10 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl &Operands, // AddRecs require their operands be loop-invariant with respect to their // loops. Don't perform this transformation if it would break this // requirement. - bool AllInvariant = true; - for (unsigned i = 0, e = Operands.size(); i != e; ++i) - if (!isLoopInvariant(Operands[i], L)) { - AllInvariant = false; - break; - } + bool AllInvariant = + std::all_of(Operands.begin(), Operands.end(), + [&](const SCEV *Op) { return isLoopInvariant(Op, L); }); + if (AllInvariant) { // Create a recurrence for the outer loop with the same step size. // @@ -2859,12 +2857,10 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl &Operands, maskFlags(Flags, SCEV::FlagNW | NestedAR->getNoWrapFlags()); NestedOperands[0] = getAddRecExpr(Operands, L, OuterFlags); - AllInvariant = true; - for (unsigned i = 0, e = NestedOperands.size(); i != e; ++i) - if (!isLoopInvariant(NestedOperands[i], NestedLoop)) { - AllInvariant = false; - break; - } + AllInvariant = std::all_of( + NestedOperands.begin(), NestedOperands.end(), + [&](const SCEV *Op) { return isLoopInvariant(Op, NestedLoop); }); + if (AllInvariant) { // Ok, both add recurrences are valid after the transformation. // @@ -8127,10 +8123,9 @@ const SCEV *SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range, // The only time we can solve this is when we have all constant indices. // Otherwise, we cannot determine the overflow conditions. - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (!isa(getOperand(i))) - return SE.getCouldNotCompute(); - + if (std::any_of(op_begin(), op_end(), + [](const SCEV *Op) { return !isa(Op);})) + return SE.getCouldNotCompute(); // Okay at this point we know that all elements of the chrec are constants and // that the start element is zero. -- 2.34.1