LLVM has fixed and vscale vectors. Casting between them is generally not allowed. Use of llvm.vector.insert.* and llvm.vector.extract.* should be a way to accomplish a zero cost conversion if the hardware size is constrained to a specific value. The function attribute `vscale_range is the way to specify a constraint on the vector hardware width being compiled for. This is very unreliable.
Targeting a known vector size on variable vector size CPUs is an important use case for just in time compilation and known hardware situations (e.g. writing firmware.) That LLVM cannot compile straight forward fixed length vector code for ARM SVE and RISC V vector is a significant productivity blocker.
A minimal LLVM IR test case and stack trace are provided below. This works if the hardware vector size is asserted via backend specific flags such as -riscv-v-vector-bits-min, -riscv-v-vector-bits-max, -aarch64-sve-vector-bits-min, -aarch64-sve-vector-bits-min. One potential design fix would be to make these fixed width flags into per function attributes or part of the target options somehow.
LLVM has fixed and vscale vectors. Casting between them is generally not allowed. Use of
llvm.vector.insert.*
andllvm.vector.extract.*
should be a way to accomplish a zero cost conversion if the hardware size is constrained to a specific value. The function attribute`vscale_range
is the way to specify a constraint on the vector hardware width being compiled for. This is very unreliable.Targeting a known vector size on variable vector size CPUs is an important use case for just in time compilation and known hardware situations (e.g. writing firmware.) That LLVM cannot compile straight forward fixed length vector code for ARM SVE and RISC V vector is a significant productivity blocker.
A minimal LLVM IR test case and stack trace are provided below. This works if the hardware vector size is asserted via backend specific flags such as
-riscv-v-vector-bits-min
,-riscv-v-vector-bits-max
,-aarch64-sve-vector-bits-min
,-aarch64-sve-vector-bits-min
. One potential design fix would be to make these fixed width flags into per function attributes or part of the target options somehow.Command to reproduce the failure:
Command which illustrates machine specific (global) fixed width flags correct the error:
test.ll input:
Stack trace: