Hi, for a generic vec_construct from scalar elements we need to load each scalar element and move it over to a vector register. This patch uses register-move cost and scalar_to_vec and multiplies it with the number of elements in the vector.
This helps vectorization of e.g. x264 SATD with the default -mvector-strict-align. Regtested on rv64gcv_zvl512b. Regards Robin PR target/118019 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_builtin_vectorization_cost): Increase vec_construct cost. --- gcc/config/riscv/riscv.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index be2ebf9d9c0..aa8a4562d9a 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -12263,7 +12263,13 @@ riscv_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, return fp ? common_costs->fp_stmt_cost : common_costs->int_stmt_cost; case vec_construct: - return estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype)); + { + /* TODO: This is too pessimistic in case we can splat. */ + int regmove_cost = fp ? costs->regmove->FR2VR + : costs->regmove->GR2VR; + return (regmove_cost + common_costs->scalar_to_vec_cost) + * estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype)); + } default: gcc_unreachable (); -- 2.47.1