[llvm] [LLVM] Add `llvm.masked.compress` intrinsic (PR #92289)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 13:24:12 PDT 2024
RKSimon wrote:
For reference this is what I had in mind:
```cpp
// Consecutively place selected values in a vector.
using VecT __attribute__((vector_size(N))) = int;
VecT compress(VecT base, VecT vec, VecT mask) {
VecT out = base;
int idx = 0;
for (int i = 0; i < N / sizeof(int); ++i) {
out[idx] = vec[i];
idx += static_cast<bool>(mask[i]);
}
return out;
}
```
If we can't do this, its not very difficult to work around (count number of active mask elements and use that to create a shuffle/select mask), but it is extra work - and the initial initialization above seems pretty trivial to add to the implementation.
https://github.com/llvm/llvm-project/pull/92289
More information about the llvm-commits
mailing list