Skip to content

Commit 9a817b8

Browse files
[Support] Use llvm::inverse_children (NFC)
1 parent ac6d2f1 commit 9a817b8

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

llvm/include/llvm/Support/GenericLoopInfo.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,14 @@ template <class BlockT, class LoopT> class LoopBase {
241241
bool isLoopLatch(const BlockT *BB) const {
242242
assert(!isInvalid() && "Loop not in a valid state!");
243243
assert(contains(BB) && "block does not belong to the loop");
244-
245-
BlockT *Header = getHeader();
246-
auto PredBegin = GraphTraits<Inverse<BlockT *>>::child_begin(Header);
247-
auto PredEnd = GraphTraits<Inverse<BlockT *>>::child_end(Header);
248-
return std::find(PredBegin, PredEnd, BB) != PredEnd;
244+
return llvm::is_contained(inverse_children<BlockT *>(getHeader()), BB);
249245
}
250246

251247
/// Calculate the number of back edges to the loop header.
252248
unsigned getNumBackEdges() const {
253249
assert(!isInvalid() && "Loop not in a valid state!");
254-
unsigned NumBackEdges = 0;
255-
BlockT *H = getHeader();
256-
257-
for (const auto Pred : children<Inverse<BlockT *>>(H))
258-
if (contains(Pred))
259-
++NumBackEdges;
260-
261-
return NumBackEdges;
250+
return llvm::count_if(inverse_children<BlockT *>(getHeader()),
251+
[&](BlockT *Pred) { return contains(Pred); });
262252
}
263253

264254
//===--------------------------------------------------------------------===//
@@ -336,7 +326,7 @@ template <class BlockT, class LoopT> class LoopBase {
336326
void getLoopLatches(SmallVectorImpl<BlockT *> &LoopLatches) const {
337327
assert(!isInvalid() && "Loop not in a valid state!");
338328
BlockT *H = getHeader();
339-
for (const auto Pred : children<Inverse<BlockT *>>(H))
329+
for (const auto Pred : inverse_children<BlockT *>(H))
340330
if (contains(Pred))
341331
LoopLatches.push_back(Pred);
342332
}

0 commit comments

Comments
 (0)