Maybe we need to introduce new option like 'vr2gpr-cost' here? Or just consider 
they would be the same.
If we need a new option that indicate the cost from vr2gpr, this may not be 
good fix up to a point.

Pan

-----Original Message-----
From: Li, Pan2 <[email protected]> 
Sent: Monday, February 2, 2026 2:48 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; 
[email protected]; Chen, Ken <[email protected]>; Liu, Hongtao 
<[email protected]>; Li, Pan2 <[email protected]>
Subject: [PATCH v1 1/2] RISC-V: Bugfix adjust_stmt_cost doesn't honor 
param=gpr2vr-cost [PR123916]

From: Pan Li <[email protected]>

After the middle-end involve slp_node and vectype to the
record_stmt_cost, we found some test like vx_vf/vx-4* is failed
to vectorize.  Per-suggestion from Richard, it is a backend issue that
makes the vector costs is greater than scalar.

After some investigation, the adjust_stmt_cost doesn't pick up the
param from command line and always get 2 here.

        PR/target 123916

gcc/ChangeLog:

        * config/riscv/riscv-vector-costs.cc (costs::adjust_stmt_cost):

Signed-off-by: Pan Li <[email protected]>
---
 gcc/config/riscv/riscv-vector-costs.cc | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gcc/config/riscv/riscv-vector-costs.cc 
b/gcc/config/riscv/riscv-vector-costs.cc
index 782796ed43e..1d137a61fb9 100644
--- a/gcc/config/riscv/riscv-vector-costs.cc
+++ b/gcc/config/riscv/riscv-vector-costs.cc
@@ -1249,13 +1249,10 @@ costs::adjust_stmt_cost (enum vect_cost_for_stmt kind, 
loop_vec_info loop,
   switch (kind)
     {
     case scalar_to_vec:
+    case vec_to_scalar:
       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
-                   : costs->regmove->VR2GR);
-      break;
     case vector_load:
     case vector_store:
        {
-- 
2.43.0

Reply via email to