On 06/05/2025 15:06, Jeff Law wrote:
diff --git gcc/config/riscv/riscv.cc gcc/config/riscv/riscv.cc
index 38f3ae7cd84..0f0cf04bdd9 100644
--- gcc/config/riscv/riscv.cc
+++ gcc/config/riscv/riscv.cc
@@ -3864,6 +3864,18 @@ riscv_rtx_costs (rtx x, machine_mode mode, int
outer_code, int opno ATTRIBUTE_UN
if (riscv_v_ext_mode_p (mode))
{
*total = COSTS_N_INSNS (1);
+ if ((GET_CODE (x) == PLUS || GET_CODE (x) == MINUS) &&
outer_code == SET)
+ {
+ rtx plus_op0 = XEXP (x, 0);
+ if (GET_CODE (plus_op0) == MULT)
+ {
+ rtx mult_op0 = XEXP (plus_op0, 0);
+ if (GET_CODE (mult_op0) == VEC_DUPLICATE)
+ {
+ *total += get_vector_costs ()->regmove->FR2VR;
+ }
+ }
+ }
return true;
}
So this probably needs minor updates now that Pan's code is in, though I
suspect combining your work and his in the costing code will be trivial.
Functionally, I would suggest one change:
if (FLOAT_MODE_P (mode))
*total += get_vector_costs ()->regmove->FR2VR;
else
*total += get_vector_costs ()->regmove->GR2VR;
That way costing ought to work for the vector integer multiply-add/sub
operations as well.
You'll need to double check if FLOAT_MODE_P works on a vector mode, if
not, you may need to get the inner mode.
Thanks Jeff. I will rebase and update my patch. One question though, I
noticed that Pan's patch introduced a command-line parameter to tweak
the GR2VR cost; do we need something equivalent for FR2VR?
--
PA