[llvm] r269767 - [LCSSA] Use any_of() to simplify the code. NFCI.
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 16:42:24 PDT 2016
derp, I was looking at the other getNode call, nevermind.
On Tue, May 17, 2016 at 3:44 PM, Sean Silva <chisophugis 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) {
>> + return DT.dominates(DomNode, DT.getNode(EB));
>>
>
> After this change, DT.getNode is evaluated every time through the loop
> instead of once at the beginning. Is that a problem?
>
> -- Sean Silva
>
>
>> + });
>> }
>>
>> bool llvm::formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI,
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160518/834a05ed/attachment.html>
More information about the llvm-commits
mailing list