[RISCV] Loosen some restrictions on lowering constant BUILD_VECTORs using vid.v.
authorCraig Topper <craig.topper@sifive.com>
Mon, 6 Dec 2021 17:06:48 +0000 (09:06 -0800)
committerCraig Topper <craig.topper@sifive.com>
Mon, 6 Dec 2021 17:34:40 +0000 (09:34 -0800)
commitacdbd34cfb810a0587e17bfb4afc66b6b55f25ba
treec6036f91a4933003270402ea13dbdeffd6911b6c
parent744aa09f5218f7db206af2e1945e23f90df46f1f
[RISCV] Loosen some restrictions on lowering constant BUILD_VECTORs using vid.v.

The immediate size check on StepNumerator did not take into account
that vmul.vi does not exist. It also did not account for power of 2
constants that can be done with vshl.vi.

This patch fixes this by moving the conversion from mul to shift
further up. Then we can consider the immediates separately for MUL
vs SHL. For MUL I've allowed simm12 which requires a single addi
before a vmul.vx. For SHL I've allowed any uimm5 which works with
vshl.vi. We could relax these further in the future. This is a
starting point that allows us to emit the same number of instructions
we were already using for smaller numerators.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D115081
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll