[llvm] [Uniformity] Fixed control-div early stop (PR #139667)
Junjie Gu via llvm-commits
llvm-commits at lists.llvm.org
Mon May 19 09:59:47 PDT 2025
jgu222 wrote:
This changes seems handling the cases that IPD cannot handle. With your comments, I looked into it further and conclude that
> > Note that the IPD is the exact place where the propagation of labels should stop, because that is the last join point of `DivTermBlock`.
This is a little tricky. If the execution favors A->E1->E2 cycles, ie, if there is any active lanes going to E1, the code will execute E1. The execution goes from A to B only if all active lanes at A goes to B. If so, E1 is not a join point. This is more like a lit test under AMDGPU/irreducible/irreducible-2.ll::@natural_loop_two_backedges(), which has the following CFG:
```
; entry
; |
; H<-|<-|
; | | |
; B-> |
; | |
; C----->
; |
; X
```
B is DivTermBlock, is ph in H uniform ? If the execution will honor the inner loop first, the phi in H is uniform. If the execution at B favors C (outer loop), then phi in H is divergent.
Unless we are sure the inner loop is always favored, we have to treat phi in H as divergent. This also means that IPD isn't necessarily convergence point. If so, IPD should not be used. Is IPD the max-convergence ?
This patch (139667) does not assume IPD is a convergence point. It will show E1 is a join if making this example a reducible CFG by removing entry->E2 edge.
https://github.com/llvm/llvm-project/pull/139667
More information about the llvm-commits
mailing list