[PATCH] D64359: [LOOPINFO] Add member function to retrieve loops in breadth-first order

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 14:34:30 PDT 2019


jdoerfert added inline comments.


================
Comment at: llvm/include/llvm/Analysis/LoopInfo.h:363
+        BreadthFirstWorklist.insert(BreadthFirstWorklist.begin(),
+                                    SubLoops.rbegin(), SubLoops.rend());
+        BreadthFirstLoops.append(SubLoops.begin(), SubLoops.end());
----------------
This is just a hunch but isn't this potentially expensive? What if we do not remove old elements in the worklist, e.g.:

```
while (Idx < Worklist.size()) {
  L = Worklist[Idx++];
  Worklist.append(L->begin(), L->end());
  BreadthFirstLoops.append(L->begin(), L->end());
}
```

Unrelated, why `rbegin`/`rend`? I would not associate an order in the loop levels with BFS, maybe document that there is one if you use these.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64359/new/

https://reviews.llvm.org/D64359





More information about the llvm-commits mailing list