@@ -241,24 +241,14 @@ template <class BlockT, class LoopT> class LoopBase {
241
241
bool isLoopLatch (const BlockT *BB) const {
242
242
assert (!isInvalid () && " Loop not in a valid state!" );
243
243
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);
249
245
}
250
246
251
247
// / Calculate the number of back edges to the loop header.
252
248
unsigned getNumBackEdges () const {
253
249
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); });
262
252
}
263
253
264
254
// ===--------------------------------------------------------------------===//
@@ -336,7 +326,7 @@ template <class BlockT, class LoopT> class LoopBase {
336
326
void getLoopLatches (SmallVectorImpl<BlockT *> &LoopLatches) const {
337
327
assert (!isInvalid () && " Loop not in a valid state!" );
338
328
BlockT *H = getHeader ();
339
- for (const auto Pred : children<Inverse< BlockT *> >(H))
329
+ for (const auto Pred : inverse_children< BlockT *>(H))
340
330
if (contains (Pred))
341
331
LoopLatches.push_back (Pred);
342
332
}
0 commit comments