[llvm] [SPIR-V] Fix block sorting with irreducible CFG (PR #116996)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 12:55:20 PST 2024
https://github.com/s-perron commented:
I'm not sure if this works for irreducible regions because I am not sure what we are trying to accomplish.
This seems to be the strategy: if no node in `toVisit` has all of it predecessor ranked yet, then essentially randomly pick a node in `toVisit` as the next node.
Theoretically we could have:
A -> B
A -> C
A -> D
B -> C
B -> D
C -> B
In this case, you will get stuck with `toVisit = { B, C, D }`. Do we care if we choose `D` next, even if it is not part of the irreducible region? This would mean that `D` will have the same rank as `B` and `C`, and will have the earlier traversal number for the tie-breaker.
I tryed to find the restrictions on block order in spir-v. All I found was:
> The order of blocks in a function must satisfy the rule that blocks appear before all blocks they dominate.
If this is the only restriction, then we can do a much simpler algorithm: any pre-order traversal of the dominator tree.
I thought there was an restriction where a constructs has to be properly nested in each other for structured control flow. So we could not have H1, H2, M1, M2 where H<i> is a header with M<i> as its merge block. However, I cannot find that.
https://github.com/llvm/llvm-project/pull/116996
More information about the llvm-commits
mailing list