[llvm] 9a817b8 - [Support] Use llvm::inverse_children (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 20:23:11 PST 2024
Author: Kazu Hirata
Date: 2024-01-17T20:23:02-08:00
New Revision: 9a817b82bbef95880db900e20ddc840dc9921ced
URL: https://github.com/llvm/llvm-project/commit/9a817b82bbef95880db900e20ddc840dc9921ced
DIFF: https://github.com/llvm/llvm-project/commit/9a817b82bbef95880db900e20ddc840dc9921ced.diff
LOG: [Support] Use llvm::inverse_children (NFC)
Added:
Modified:
llvm/include/llvm/Support/GenericLoopInfo.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/GenericLoopInfo.h b/llvm/include/llvm/Support/GenericLoopInfo.h
index ac4f2d7010b411e..d560ca648132c94 100644
--- a/llvm/include/llvm/Support/GenericLoopInfo.h
+++ b/llvm/include/llvm/Support/GenericLoopInfo.h
@@ -241,24 +241,14 @@ template <class BlockT, class LoopT> class LoopBase {
bool isLoopLatch(const BlockT *BB) const {
assert(!isInvalid() && "Loop not in a valid state!");
assert(contains(BB) && "block does not belong to the loop");
-
- BlockT *Header = getHeader();
- auto PredBegin = GraphTraits<Inverse<BlockT *>>::child_begin(Header);
- auto PredEnd = GraphTraits<Inverse<BlockT *>>::child_end(Header);
- return std::find(PredBegin, PredEnd, BB) != PredEnd;
+ return llvm::is_contained(inverse_children<BlockT *>(getHeader()), BB);
}
/// Calculate the number of back edges to the loop header.
unsigned getNumBackEdges() const {
assert(!isInvalid() && "Loop not in a valid state!");
- unsigned NumBackEdges = 0;
- BlockT *H = getHeader();
-
- for (const auto Pred : children<Inverse<BlockT *>>(H))
- if (contains(Pred))
- ++NumBackEdges;
-
- return NumBackEdges;
+ return llvm::count_if(inverse_children<BlockT *>(getHeader()),
+ [&](BlockT *Pred) { return contains(Pred); });
}
//===--------------------------------------------------------------------===//
@@ -336,7 +326,7 @@ template <class BlockT, class LoopT> class LoopBase {
void getLoopLatches(SmallVectorImpl<BlockT *> &LoopLatches) const {
assert(!isInvalid() && "Loop not in a valid state!");
BlockT *H = getHeader();
- for (const auto Pred : children<Inverse<BlockT *>>(H))
+ for (const auto Pred : inverse_children<BlockT *>(H))
if (contains(Pred))
LoopLatches.push_back(Pred);
}
More information about the llvm-commits
mailing list