[llvm] [AMDGPU] Add intrinsic readanylane (PR #115696)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 19 03:13:05 PST 2026


ssahasra wrote:

I think SWDEV-580405 is a good use-case for readanylane. We can already detect the pattern for waveid, at which point we want to declare to the compiler that waveid is a uniform value. In that case, we can do the following:

```
%tid = call workitemid.x()
%waveid = lshr %tid, 6
%uni.waveid = readanylane %waveid
```
The proposed semantics of `readanylane(%x)` is that it returns `%x` if it is uniform, and poison otherwise. But that is too restrictive for the following transformation:

```
%tid = call workitemid.x()
%pick.one.tid = readanylane %tid
%waveid = lshr %pick.one.tid, 6
```
This works because no matter which `%tid` we pick, `%waveid` will be the same. The benefit is that we can move the inputs of an expression (and hence the entire expression) to the SALU instead of only the output of that expression. But the poison for divergent inputs does not allow us to do this transformation.

Ping @krzysz00 for attention.

https://github.com/llvm/llvm-project/pull/115696


More information about the llvm-commits mailing list