[llvm] [GenericDomTreeConstruction] Store the semidominator value in Label (PR #207603)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 5 12:44:12 PDT 2026


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

Code LG. Although I fear that more deviations from the algorithm in the thesis (which is described there rather vaguely, IMO, I remember some pieces not being explicitly written down there) probably reduces code clarity.

> I tried some SoA/AoS variations, but they didn't yield any improvements.

Yeah, SoA is mostly beneficial for vectorization, which is not applicable here, but worse if it needs multiple allocations.

> I feel like this runSemiNCA() cannot be optimized any further.

* getNodeInfo for vectors has unneeded Number+1 for pre-dominator trees and I think we can resize once at the start and then avoid the bounds check. All numbered graphs we support have a valid max block number.
* Algorithmically.. SemiNCA is O(n^2) (n=#nodes) and in my previous job we once ran into a case where we hit these somewhat badly. Other parts of LLVM also get slow quickly, but the domtree construction was at some point an expensive point. (I don't recall the details, though, this was years ago.)

Other than that, I agree, the implementation is quite good (in contrast to the dominator tree itself).

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


More information about the llvm-commits mailing list