[RISCV] Preserve fixed-length VL on insert_vector_elt in more cases
authorFraser Cormack <fraser@codeplay.com>
Wed, 3 Mar 2021 07:50:49 +0000 (07:50 +0000)
committerFraser Cormack <fraser@codeplay.com>
Thu, 4 Mar 2021 09:21:10 +0000 (09:21 +0000)
commitd8e1d2ebf47f8621cc17b5dd2401db95647554fb
tree9ff3c0c8d93f9dcf653b6bbe2837393b45d669cd
parent1bdb636661d473d731b9a0ab8d9b124037469306
[RISCV] Preserve fixed-length VL on insert_vector_elt in more cases

This patch fixes up one case where the fixed-length-vector VL was
dropped (falling back to VLMAX) when inserting vector elements, as the
code would lower via ISD::INSERT_VECTOR_ELT (at index 0) which loses the
fixed-length vector information.

To this end, a custom node, VMV_S_XF_VL, was introduced to carry the VL
operand through to the final instruction. This node wraps the RVV
vmv.s.x and vmv.s.f instructions, which were being selected by
insert_vector_elt anyway.

There should be no observable difference in scalable-vector codegen.

There is still one outstanding drop from fixed-length VL to VLMAX, when
an i64 element is inserted into a vector on RV32; the splat (which is
custom legalized) has no notion of the original fixed-length vector
type.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D97842
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-insert.ll