[TargetLowering] Improve legalization of scalable vector types
authorFraser Cormack <fraser@codeplay.com>
Fri, 7 May 2021 14:25:40 +0000 (15:25 +0100)
committerFraser Cormack <fraser@codeplay.com>
Wed, 12 May 2021 15:33:07 +0000 (16:33 +0100)
commitc5ec00e62b0e7b91eb07e25441c7ed38227f5bf3
tree9c9b67607faf2fb88e62cecd622a87bc23b7c905
parent6110b667b0537104ee139a5c6efc726f902db4de
[TargetLowering] Improve legalization of scalable vector types

This patch extends the vector type-conversion and legalization capabilities of
scalable vector types.

Firstly, `vscale x 1` types now behave more like the corresponding `vscale x
2+` types. This enables the integer promotion legalization of extended scalable
types, such as the promotion of `<vscale x 1 x i5>` to `<vscale x 1 x i8>`.

These `vscale x 1` types are also now better handled by
`getVectorTypeBreakdown`, where what looks like older handling for 1-element
fixed-length vector types was spuriously updated to include scalable types.

Widening of scalable types is now better supported, by using `INSERT_SUBVECTOR`
to insert the smaller scalable vector "value" type into the wider scalable
vector "part" type. This allows AArch64 to pass and return `vscale x 1` types
by value by widening.

There are still cases where we are unable to legalize `vscale x 1` types, such
as where expansion would require splitting the vector in two.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D102073
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/test/CodeGen/AArch64/sve-widen-scalable-vectortype.ll [new file with mode: 0644]
llvm/test/CodeGen/RISCV/rvv/legalize-scalable-vectortype.ll [new file with mode: 0644]