[RISCV] Add support for bitcasts between scalars and fixed-length vectors
authorFraser Cormack <fraser@codeplay.com>
Wed, 31 Mar 2021 16:01:16 +0000 (17:01 +0100)
committerFraser Cormack <fraser@codeplay.com>
Mon, 5 Apr 2021 16:21:55 +0000 (17:21 +0100)
commitaf3a839c70adb97323fa3d122e9ab44522dca74e
tree944bc25bb1e4458be65bb5f3859c8c9d378d3b40
parentc590a9880d7a660a1c911fce07f3d01ea18be2df
[RISCV] Add support for bitcasts between scalars and fixed-length vectors

This patch supports bitcasts from scalar types to fixed-length vectors
and vice versa. It custom-lowers and custom-legalizes them to
EXTRACT_VECTOR_ELT/INSERT_VECTOR_ELT operations, using a single-element
vectors to hold the scalar where appropriate.

Previously, some of these would fail to select, others would be expanded
through stack loads and stores. Effort was made to ensure the codegen
avoids the stack for both legal and illegal scalar types.

Some of the codegen could be improved, but on first glance it looks like
a general optimization of EXTRACT_VECTOR_ELT when extracting an i64
element on RV32.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D99667
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-bitcast.ll
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-bitcast.ll [new file with mode: 0644]