https://gcc.gnu.org/g:03d5c7af1264b432eb19c317d19474fa5b0a7acc
commit 03d5c7af1264b432eb19c317d19474fa5b0a7acc Author: Paul-Antoine Arras <par...@baylibre.com> Date: Wed May 28 12:09:22 2025 +0200 RISC-V: Use helper function to get FPR to VR move cost Since last patch introduced get_fr2vr_cost () to get the correct cost to move data from a floating-point to a vector register, this patch replaces existing uses of the constant FR2VR. gcc/ChangeLog: * config/riscv/riscv-vector-costs.cc (costs::adjust_stmt_cost): Replace FR2VR with get_fr2vr_cost (). * config/riscv/riscv.cc (riscv_register_move_cost): Likewise. (riscv_builtin_vectorization_cost): Likewise. (cherry picked from commit 5566b20dd5f7fa14d93d2808414bf72882ec567e) Diff: --- gcc/config/riscv/riscv-vector-costs.cc | 4 ++-- gcc/config/riscv/riscv.cc | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc index a39b611e4cef..4d8170de9b2c 100644 --- a/gcc/config/riscv/riscv-vector-costs.cc +++ b/gcc/config/riscv/riscv-vector-costs.cc @@ -1099,8 +1099,8 @@ costs::adjust_stmt_cost (enum vect_cost_for_stmt kind, loop_vec_info loop, switch (kind) { case scalar_to_vec: - stmt_cost += (FLOAT_TYPE_P (vectype) ? costs->regmove->FR2VR - : get_gr2vr_cost ()); + stmt_cost + += (FLOAT_TYPE_P (vectype) ? get_fr2vr_cost () : get_gr2vr_cost ()); break; case vec_to_scalar: stmt_cost += (FLOAT_TYPE_P (vectype) ? costs->regmove->VR2FR diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index ecacd7d178e9..06a8b5175c2b 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -9797,7 +9797,7 @@ riscv_register_move_cost (machine_mode mode, if (from_is_gpr) return get_gr2vr_cost (); else if (from_is_fpr) - return get_vector_costs ()->regmove->FR2VR; + return get_fr2vr_cost (); } return riscv_secondary_memory_needed (mode, from, to) ? 8 : 2; @@ -12743,8 +12743,7 @@ riscv_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, case vec_construct: { /* TODO: This is too pessimistic in case we can splat. */ - int regmove_cost = fp ? costs->regmove->FR2VR - : get_gr2vr_cost (); + int regmove_cost = fp ? get_fr2vr_cost () : get_gr2vr_cost (); return (regmove_cost + common_costs->scalar_to_vec_cost) * estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype)); }