[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 07:24:42 PDT 2016
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));
+ });
}
bool llvm::formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI,
More information about the llvm-commits
mailing list