[llvm] [AMDGPU] Add intrinsic readanylane (PR #115696)
Sameer Sahasrabuddhe via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 23:07:50 PST 2024
ssahasra wrote:
```
A: x = def(); B: x = def();
y = read*lane(x); if (divergentcondition) {
if (divergentcondition) { y = read*lane(x);
use(y); use(y);
} }
```
I am not sure what is the primary goal here. If the goal is to allow certain defs to be sunk into divergent control flow, then maybe this particular situation is sufficient justification to add a new attribute that allows allow sinking. This can be combined with builtin that declares "uniform at use". A combination of these two will allow the `A --> B` transformation.
In program B, being able to say that a value is uniform at its use inside divergent control-flow can be useful in itself. Trying to hoist this value like in `B --> A` is hard anyway. This should be considered separately from the `A --> B` transform. In the program B, if the user wanted the value to be hoisted, then they probably have sufficient information to write A instead.
Syntax-wise, I am leaning more towards something that looks like `@llvm.assume`. In fact, we could consider `@llvm.is_uniform` as a builtin predicate, and then the user can say `@llvm.assume(@llvm.is_uniform())`. This is similar to the existing `@llvm.is.constant.*` builtins.
https://github.com/llvm/llvm-project/pull/115696
More information about the llvm-commits
mailing list