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

Robin Kruppe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 08:10:42 PST 2020


rkruppe added a comment.

In D57504#1851864 <https://reviews.llvm.org/D57504#1851864>, @cameron.mcinally wrote:

> > Btw, I guess that https://reviews.llvm.org/D71432 shows that op+select folding can be cleanly implemented in isel and that's also in line with my experiments for the VE target.
>
> This needs a caveat. Keeping the select glued to the operation takes some careful effort. Especially in the undef passthru case, there are a bunch of peeps that will incorrectly fold away the select. E.g. this transform from InstSimplify:
>
>   if (isa<UndefValue>(FalseVal))   // select ?, X, undef -> X
>     return TrueVal;
>   
>
> The VP intrinsics will certainly be immune to these, but if the plan is to eventually replace the VP select intrinsics with IR selects, then this problem will need to be solved. Just a heads up...


As Eli argued in that patch, IR like `select %m, (constrained.fadd %a, %b), %passthru` is not expressing a predicated vector add, and must not be selected as such. The IR semantics are unambiguously: first a full vector add is performed (with all exceptions etc. that entails, or possible UB in related cases like integer division) and then some of the resulting lanes are replaced with values from `%passthru`. To predicate the fadd itself, a dedicated operation/intrinsic is needed. LLVM IR does not currently (and should not) change the meaning of the regular unpredicated operations based on (some? any?) uses of the value being a `select`. The only thing a `select` (or `vp.select`) can do is alter the lanes of a vector after it has been computed, it cannot travel back in time to change how it was computed.

VP intrinsics are the aforementioned predicated operations: in certain lanes, no computation (which might raising FP exceptions, have UB, etc.) happens and the resulting vector has some "default value" instead. The present discussion about whether to include a `%passthru` argument is just about how this default value is determined. But this does not change that the operation itself is predicated, it just affects how you express e.g. the patterns that map to SVE's zeroing and merging predication.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57504





More information about the llvm-commits mailing list