[PATCH] D26348: Allow convergent attribute for function arguments

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 09:25:44 PST 2017


sanjoy added a comment.

In https://reviews.llvm.org/D26348#694393, @mehdi_amini wrote:

> In https://reviews.llvm.org/D26348#694245, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D26348#693574, @mehdi_amini wrote:
> >
> > > My point is that one can't choose performance and sacrifices knowingly correctness, and then complains about a LLVM bug that need to be fixed. The bug is in the shader compiler in the first place!
> >
> >
> > I missed the rationale for this statement, but this does not seem obviously correct to me. Even marking the intrinsics as having unknown side effects does not seem strong enough to ensure the semantics required here - we don't really have a strong definition for "unknown side effects", AFAIK, but I'd not have thought that even unknown side effects on Foo would prevent the folding of:
> >
> >   if (cond) {
> >     Tmp1 = Foo(v [convergent])
> >   } else {
> >     Tmp2 = Foo(v [convergent])
> >   }
> >   Tmp3 = phi [Tmp1, Tmp2]
>
>
> You're totally correct. I don't see any attribute that would model the convergent effect.
>  The issue stays the same: the intrinsic are "lying" by using SSA value with an unmodeled constraints.
>
> >> Example to think about: can token help? Could the intrinsic be modeled by taking a pointer to a memory location instead of a SSA value? (there are finer grain way to express the effect on a pointer argument, and it wouldn't break SSA).
>
> Let me expand on this aspect instead, what about something like:
>
>   void foo(int v, bool cond) {
>     if (cond) {
>       token1 = statepoint()
>       bar(v, token1); // v needs to be convergent
>     } else {
>       token2 = statepoint()
>       bar(v, token2);  // v needs to be convergent
>     }
>   }
>
>
> This is trying to capture the value of v at a given point using the token to bind the call to bar to this particular value of v.


Is it okay to fold that to:

  void foo(int v, bool cond) {
    if (cond) {
      // token1 = statepoint()
      // bar(v, token1); // v needs to be convergent
    } else {
      // token2 = statepoint()
      // bar(v, token2);  // v needs to be convergent
    }
    token_merged = statepoint()
    bar(v, token_merged); // v needs to be convergent
  }


https://reviews.llvm.org/D26348





More information about the llvm-commits mailing list