[llvm] r269767 - [LCSSA] Use any_of() to simplify the code. NFCI.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 12:07:52 PDT 2016
On Tue, May 17, 2016 at 7:21 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Tue, May 17, 2016 at 7:24 AM, Davide Italiano via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: davide
>> Date: Tue May 17 09:24:41 2016
>> New Revision: 269767
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269767&view=rev
>> Log:
>> [LCSSA] Use any_of() to simplify the code. NFCI.
>>
>> Modified:
>> llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=269767&r1=269766&r2=269767&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Tue May 17 09:24:41 2016
>> @@ -53,10 +53,8 @@ STATISTIC(NumLCSSA, "Number of live out
>> /// Return true if the specified block is in the list.
>> static bool isExitBlock(BasicBlock *BB,
>> const SmallVectorImpl<BasicBlock *> &ExitBlocks)
>> {
>> - for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
>> - if (ExitBlocks[i] == BB)
>> - return true;
>> - return false;
>> + return std::any_of(ExitBlocks.begin(), ExitBlocks.end(),
>> + [&](BasicBlock *EB) { return EB == BB; });
>> }
>>
>> /// Given an instruction in the loop, check to see if it has any uses
>> that are
>> @@ -210,11 +208,9 @@ blockDominatesAnExit(BasicBlock *BB,
>> DominatorTree &DT,
>> const SmallVectorImpl<BasicBlock *> &ExitBlocks) {
>> DomTreeNode *DomNode = DT.getNode(BB);
>> - for (BasicBlock *ExitBB : ExitBlocks)
>> - if (DT.dominates(DomNode, DT.getNode(ExitBB)))
>> - return true;
>> -
>> - return false;
>> + return std::any_of(ExitBlocks.begin(), ExitBlocks.end(), [&](BasicBlock
>> *EB) {
>
>
> FWIW, in STLExtras.h we have llvm::any_of that takes a range rather than
> begin/end iterators, so it's a bit more compact if you prefer to use that.
>
r269800. As always, thanks for your post-commit review(s).
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list