[PATCH] D57504: RFC: Prototype & Roadmap for vector predication in LLVM

Simon Moll via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 08:20:02 PDT 2019


simoll added a comment.

In D57504#1720792 <https://reviews.llvm.org/D57504#1720792>, @shawnl wrote:

> Are predicated vector instructions not just a special case of DemandedBits? Why can't we leave out the .vp. intrinsics, and just generate the predicate with DemandedBits? That way you do a predicated vector operation like so (in zig): As the example makes clear, this optimization would have to be guaranteed in order for the generated code to be correct (as the predicate avoids a divide-by-zero error).
>
> var notzero = v != 0;
>  if (std.vector.any(notzero)) {
>
>   v = std.vector.select(5 / v, v, notzero);
>
> }


What you describe is a workaround but not a solution for predicated SIMD in LLVM.
This approach may seem natural considering SIMD ISAs, such as x86 SSE, ARM NEON, that do not have predication.
It is however a bad fit for SIMD instruction sets that do support predicated SIMD (AVX512, ARM SVE, RISC-V V, NEC SX-Aurora).

As it turns out, it is more robust to have predicated instructions right in LLVM IR and convert them to the instruction+select pattern for SSE and friends than going the other way round.
This is what LLVM-VP proposes.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57504





More information about the llvm-commits mailing list