[llvm] [LoopInfo] Reuse DomTree's own DFS numbering in analyze() (PR #207650)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 00:49:19 PDT 2026


https://github.com/aengelke approved this pull request.

LGTM. Consider adding the following explanations to the commit message:

- The change from post-order to reverse pre-order changes the order in which the children of a node are visited (reverse preorder: last child visited first, post order: last child visited last). There is no difference, because the sub-loop and block vectors are only filled in the PopulateLoopDFS traversal later on.
- post_order (and, likewise, depth_first) are inefficient for tree traversals: DomTreeNodeBase doesn't expose graph numbers, so the traversal keeps a SmallPtrSet of visited nodes. For a tree, tracking visited nodes is moreover completely unnecessary, as by definition every node is only reachable from one parent. (NB: IIRC we have other users of post_order/depth_first of dominator trees as well.)


https://github.com/llvm/llvm-project/pull/207650


More information about the llvm-commits mailing list