RE: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-29 Thread Li, Pan2
.zh...@rivai.ai; kito.ch...@gmail.com; jeffreya...@gmail.com; Chen, Ken ; Liu, Hongtao ; Robin Dapp Subject: Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost > I see, let the vec_dup enter the rtx_cost again to append the total to vmv, I > have a try testi

Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-29 Thread Robin Dapp
I see, let the vec_dup enter the rtx_cost again to append the total to vmv, I have a try testing. For example with below change: + switch (rcode) + { + case VEC_DUPLICATE: + *total += get_vector_costs ()->regmove->GR2VR * COSTS_N_INSNS (1); + break; +

RE: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-29 Thread Li, Pan2
m: Robin Dapp Sent: Tuesday, April 29, 2025 2:31 PM To: Li, Pan2 ; Robin Dapp ; gcc-patches@gcc.gnu.org Cc: juzhe.zh...@rivai.ai; kito.ch...@gmail.com; jeffreya...@gmail.com; Chen, Ken ; Liu, Hongtao ; Robin Dapp Subject: Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx

Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-28 Thread Robin Dapp
But this is not that good enough here if my understanding is correct. As vmv.v.x is somehow equivalent to vec_dup but doesn't ref GR2VR, But it should. Can't we do something like: if (riscv_v_ext_mode_p (mode)) { switch (GET_CODE (x)) { case VEC_DUPLICATE:

RE: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-28 Thread Li, Pan2
Dapp ; gcc-patches@gcc.gnu.org Cc: juzhe.zh...@rivai.ai; kito.ch...@gmail.com; jeffreya...@gmail.com; Chen, Ken ; Liu, Hongtao ; Robin Dapp Subject: Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost > Make sense to me, it looks like the combine will always t

Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-28 Thread Robin Dapp
Make sense to me, it looks like the combine will always take place if GR2VR is 0, 1 or 2 for now. I am try to customize the cost here to make it fail to combine but get failed with below change. + if (rcode == VEC_DUPLICATE && SCALAR_INT_MODE_P (GET_MODE (XEXP (x, 0 { +cost_val = 1; +

RE: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-25 Thread Li, Pan2
(weighted: 35.923637), replacement cost = 32 (weighted: 258.909092); rejecting replacement 61 │ Pan -Original Message- From: Robin Dapp Sent: Thursday, April 24, 2025 8:13 PM To: Li, Pan2 ; Robin Dapp ; gcc-patches@gcc.gnu.org Cc: juzhe.zh...@rivai.ai; kito.ch...@gmail.com; je

Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-24 Thread Robin Dapp
Ah, I see, thanks. So vec_dup costs 1 + 2 and vadd.vv costs 1 totalling 4 while vadd.vx costs 1 + 2, making it cheaper? Yes, looks we need to just assign the GR2VR when vec_dup. I also tried diff cost here to see the impact to late-combine. + if (rcode == VEC_DUPLICATE && SCALAR_INT_MODE_P (

RE: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-23 Thread Li, Pan2
to the series. Pan -Original Message- From: Robin Dapp Sent: Wednesday, April 23, 2025 3:01 PM To: Li, Pan2 ; Robin Dapp ; gcc-patches@gcc.gnu.org Cc: juzhe.zh...@rivai.ai; kito.ch...@gmail.com; jeffreya...@gmail.com; Chen, Ken ; Liu, Hongtao ; Robin Dapp Subject: Re: [PATCH v2 1/3] R

Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-23 Thread Robin Dapp
The only thing I think we want for the patch (as Pan also raised last time) is the param to set those .vx costs to zero in order to ensure the tests test the right thing (--param=vx_preferred/gr2vr_cost or something). I see, shall we start a new series for this? AFAIK, we may need some more al

RE: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-22 Thread Li, Pan2
m: Robin Dapp Sent: Tuesday, April 22, 2025 11:10 PM To: Li, Pan2 ; gcc-patches@gcc.gnu.org Cc: juzhe.zh...@rivai.ai; kito.ch...@gmail.com; jeffreya...@gmail.com; rdapp@gmail.com; Chen, Ken ; Liu, Hongtao ; Robin Dapp Subject: Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx

Re: [PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-22 Thread Robin Dapp
/* TODO: We set RVV instruction cost as 1 by default. Cost Model need to be well analyzed and supported in the future. */ + int cost_val = 1; + enum rtx_code rcode = GET_CODE (x); + + /* Aka (vec_duplicate:RVVM1DI (reg/v:DI 143 [ x ])) */ + if (rcode == VEC_DUPLICATE && SCALAR_INT_MO

[PATCH v2 1/3] RISC-V: Combine vec_duplicate + vadd.vv to vadd.vx on GR2VR cost

2025-04-19 Thread pan2 . li
From: Pan Li This patch would like to combine the vec_duplicate + vadd.vv to the vadd.vx. From example as below code. The related pattern will depend on the cost of vec_duplicate from GR2VR, it will: * The pattern matching will be inactive if GR2VR cost is zero. * The cost of GR2VR will be add