https://gcc.gnu.org/g:f38ebe459af792e097d7923dd49dc19d79d52427

commit r16-3075-gf38ebe459af792e097d7923dd49dc19d79d52427
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Aug 7 14:45:52 2025 +0200

    Pass SLP node to promotion/demotion costing
    
    This one was forgotten.  Also constants/externals are costed explicitly
    with SLP.
    
            * tree-vect-stmts.cc (vect_model_promotion_demotion_cost): Pass
            in SLP node and drop unused dr argument.  Use SLP node for
            costing, drop costing of constant/external operands.
            (vectorizable_conversion): Adjust.

Diff:
---
 gcc/tree-vect-stmts.cc | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 92bda1c20cf3..eff5e8893081 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -929,8 +929,7 @@ vect_model_simple_cost (vec_info *, int n, slp_tree node,
    is true the stmt is doing widening arithmetic.  */
 
 static void
-vect_model_promotion_demotion_cost (stmt_vec_info stmt_info,
-                                   enum vect_def_type *dt,
+vect_model_promotion_demotion_cost (slp_tree slp_node,
                                    unsigned int ncopies, int pwr,
                                    stmt_vector_for_cost *cost_vec,
                                    bool widen_arith)
@@ -943,16 +942,10 @@ vect_model_promotion_demotion_cost (stmt_vec_info 
stmt_info,
       inside_cost += record_stmt_cost (cost_vec, ncopies,
                                       widen_arith
                                       ? vector_stmt : vec_promote_demote,
-                                      stmt_info, 0, vect_body);
+                                      slp_node, 0, vect_body);
       ncopies *= 2;
     }
 
-  /* FORNOW: Assuming maximum 2 args per stmts.  */
-  for (i = 0; i < 2; i++)
-    if (dt[i] == vect_constant_def || dt[i] == vect_external_def)
-      prologue_cost += record_stmt_cost (cost_vec, 1, vector_stmt,
-                                        stmt_info, 0, vect_prologue);
-
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
                      "vect_model_promotion_demotion_cost: inside_cost = %d, "
@@ -5386,7 +5379,7 @@ vectorizable_conversion (vec_info *vinfo,
          SLP_TREE_TYPE (slp_node) = type_demotion_vec_info_type;
          /* The final packing step produces one vector result per copy.  */
          unsigned int nvectors = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
-         vect_model_promotion_demotion_cost (stmt_info, dt, nvectors,
+         vect_model_promotion_demotion_cost (slp_node, nvectors,
                                              multi_step_cvt, cost_vec,
                                              widen_arith);
        }
@@ -5398,7 +5391,7 @@ vectorizable_conversion (vec_info *vinfo,
             so >> MULTI_STEP_CVT divides by 2^(number of steps - 1).  */
          unsigned int nvectors
            = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) >> multi_step_cvt;
-         vect_model_promotion_demotion_cost (stmt_info, dt, nvectors,
+         vect_model_promotion_demotion_cost (slp_node, nvectors,
                                              multi_step_cvt, cost_vec,
                                              widen_arith);
        }

Reply via email to