[RISCV] Optimize floating-point "dominant value" BUILD_VECTORs
authorFraser Cormack <fraser@codeplay.com>
Wed, 28 Jul 2021 14:20:49 +0000 (15:20 +0100)
committerFraser Cormack <fraser@codeplay.com>
Thu, 29 Jul 2021 08:22:34 +0000 (09:22 +0100)
commit02dd4b59bc0d34ecd41fcc314f5571572b3feebc
treeeba1f88a4da8d3dfc226359c3f4dbe1df185d13c
parenta33f60db39836d94a79557b147515d42d30ecba3
[RISCV] Optimize floating-point "dominant value" BUILD_VECTORs

This patch aims to improve the performance of BUILD_VECTORs which are
identified as containing a dominant element. Given that most
floating-point constants themselves require a load from the constant
pool, it was possible for the optimization to actually increase the
number of individual loads on small vectors. The exception is the zero
constant -- +0.0 -- which can be materialized efficiently.

While this optimization could do with a proper cost model to weigh the
benfits of a single vector load vs. the manipulation of individual
elements -- even for integer vectors which often require several
instructions to materialize -- without a concrete RVV implementation to
work with any heuristic is likely to be both more obtuse and inaccurate.

Until then, this patch fixes at least one known obvious deficiency.

Reviewed By: craig.topper

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