[PATCH] D137142: [WIP] DivergenceAnalysis: Infer uniformity from assume calls

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 01:35:46 PST 2023


nhaehnle added a comment.

In D137142#4051045 <https://reviews.llvm.org/D137142#4051045>, @simoll wrote:

> In D137142#4046742 <https://reviews.llvm.org/D137142#4046742>, @foad wrote:
>
>>> For the DA in isolation, ideally, we'd have something like:
>>>
>>>   %Y = llvm.assume.uniform(%X)
>>>   foo(%Y) ; <- Rewritten to use %Y instead of %X.
>>
>> This is roughly what the target-specific @llvm.amdgcn.readfirstlane does today, and some frontends do use it to assert and/or enforce uniformity of particular values. There is some sublety about exactly what it means (or exactly what @llvm.assume.uniform //should// mean): Read the first active lane? Read an arbitrary active lane? Undefined/poison if active lanes do not all have the same value?
>
> Read all active lanes. The intrinsic only tells us that we can assume uniformity among the active lanes in each instance, it could not be used to enforce it. Not so sure about the values on inactive lanes, I'd say it simply passes through the incoming values.. you may just want poison here though..

We do need to say what happens if the assumptions is wrong. I believe at a minimum we need to say that the result is poison, because of what happens when the result feeds into a conditional branch: divergence analysis uses the assumption, which can affect codegen. So UB on that branch if the assumption is wrong seems like the minimum we need.

Though immediate UB is a legitimate alternative, since it would allow us to replace other uses of %X by %Y.


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

https://reviews.llvm.org/D137142



More information about the llvm-commits mailing list