[PATCH] D81806: [DivergenceAnalysis] mark join of divergent loop exits

Madhur Amilkanthwar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 06:37:20 PDT 2020


madhur13490 added a comment.

In D81806#2095487 <https://reviews.llvm.org/D81806#2095487>, @simoll wrote:

> In D81806#2094960 <https://reviews.llvm.org/D81806#2094960>, @sameerds wrote:
>
> > In D81806#2094869 <https://reviews.llvm.org/D81806#2094869>, @simoll wrote:
> >
> > > I am a bit surprised this is necessary. Actually, join divergence in `bb3` should come about as a result of `propagateLoopDivergence` for the `[bb1, bb2]` loop and not immediately because it is a divergent exit.
> >
> >
> > I am not sure what you mean here. propagateLoopDivergence is calling propagateJoinDivergence ... so doesn't that count as a result of the former?
> >
> > > Also, a divergent loop exit does not automatically become join divergent, eg:
> > > 
> > >   bb1: 
> > >      %m.uni = <uni>
> > >      %n.uni = <uni>
> > >      br <uni>, %bb2, %bb3
> > >    
> > >   bb2: [..]
> > >      br <div>, %bb2, %bb3
> > >    
> > >   bb3:
> > >      %x.uni = phi [%m.uni, %bb2], [%n.uni %bb1]  <-- divergent loop exit that is not join divergent
> >
> > But here, bb3 is not a join block for the bb2 loop, since there is only one path from the loop exit reaching bb3.
>
>
> Exactly. With this patch `%x.uni` is marked as join divergent even though it is uniform: In its present form the patch solves one issue at the cost of precision.
>
> The real culprit here is the `SDA::join_blocks` interface that does not distinguish divergent join blocks and loop exits. The SDA "knows" which is which internally, loses that information as it passes divergent blocks through `join_blocks` and the DA has to reverse-engineer that information. I have an unfinished patch here that fixes that and should resolve the bug addressed by this patch as well. The unfinished patch also factors the back-and-forth between the DA and SDA to propagate along nested loops completely into the SDA (`propagateLoopDiv` does not really belong in the DA).
>
> Long story short: This is an ok fix (but please add a FIXME/TODO that hints to the issues with this approach) but we should rework the `join_blocks` interface in any case.


I am new to this party. Why is `%x` marked as `uni`? Its value will differ amongst threads as branch in bb2 is divergent. Is my understanding incorrect?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81806





More information about the llvm-commits mailing list