[PATCH] D105119: [SVE] Fix incorrect codegen when inserting vector elements into widened scalable vectors

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 10:07:05 PDT 2021


efriedma added a reviewer: craig.topper.
efriedma added a comment.

In D105119#2849757 <https://reviews.llvm.org/D105119#2849757>, @sdesmalen wrote:

> In D105119#2848107 <https://reviews.llvm.org/D105119#2848107>, @efriedma wrote:
>
>> For non-scalable vectors, widening means we pad the end with undef elements (i.e. INSERT_SUBVECTOR into an undef vector).  Do you want it to mean something different for scalable vectors?  Is this documented somewhere?
>
> The difference is that scalable vectors are unpacked, so for `<vscale x 1 x i64>` <=> `<v0 | v1 | .... | vn-1>`, needs widening to `<vscale x 2 x i64>` <=> `<v0, _ | v1, _, | ... | vn-1, _>`, which means that the index in which to insert the element needs to be multiplied by 2. For fixed-width vectors, we'd indeed pad the number of elements in the vector to go from `<2 x i32> <v0, v1>` to `<4 x i32> <v0, v1, _, _>`, so the index stays the same. I'm not really sure where this should be documented as it's mostly a characteristic of scalable vectors, but I guess an extra comment describing it here wouldn't hurt. Note that the widening only works for `vscale x 1` because it is a power of 2. I'm not sure if it would even be possible to widen `<vscale x 3` to `<vscale x 4`.

This sounds very SVE-specific.

I'm not sure I understand why we can't pack the elements tightly.  It might be a little more verbose to widen certain SVE operations, but not impossible, and injecting SVE-specific behavior into target-independent code is messy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105119



More information about the llvm-commits mailing list