From 9a817b82bbef95880db900e20ddc840dc9921ced Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 17 Jan 2024 20:23:02 -0800 Subject: [PATCH] [Support] Use llvm::inverse_children (NFC) --- llvm/include/llvm/Support/GenericLoopInfo.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/Support/GenericLoopInfo.h b/llvm/include/llvm/Support/GenericLoopInfo.h index ac4f2d7010b4..d560ca648132 100644 --- a/llvm/include/llvm/Support/GenericLoopInfo.h +++ b/llvm/include/llvm/Support/GenericLoopInfo.h @@ -241,24 +241,14 @@ public: 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>::child_begin(Header); - auto PredEnd = GraphTraits>::child_end(Header); - return std::find(PredBegin, PredEnd, BB) != PredEnd; + return llvm::is_contained(inverse_children(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>(H)) - if (contains(Pred)) - ++NumBackEdges; - - return NumBackEdges; + return llvm::count_if(inverse_children(getHeader()), + [&](BlockT *Pred) { return contains(Pred); }); } //===--------------------------------------------------------------------===// @@ -336,7 +326,7 @@ public: void getLoopLatches(SmallVectorImpl &LoopLatches) const { assert(!isInvalid() && "Loop not in a valid state!"); BlockT *H = getHeader(); - for (const auto Pred : children>(H)) + for (const auto Pred : inverse_children(H)) if (contains(Pred)) LoopLatches.push_back(Pred); } -- 2.11.4.GIT