https://gcc.gnu.org/g:8f9348361c552e4e65ef7dc3e7788ce51a5b91c3

commit r15-4782-g8f9348361c552e4e65ef7dc3e7788ce51a5b91c3
Author: Richard Biener <rguent...@suse.de>
Date:   Wed Oct 30 13:06:08 2024 +0100

    Remove vectorizer finish_cost wrapper
    
    The inline function wraps the vector_cost class API and no longer is
    a good representation of the query style of that class which makes it
    also difficult to extend.
    
            * tree-vectorizer.h (finish_cost): Inline everywhere and remove.
            * tree-vect-loop.cc (vect_estimate_min_profitable_iters):
            Inline finish_cost.
            * tree-vect-slp.cc (vect_bb_vectorization_profitable_p): Likewise.

Diff:
---
 gcc/tree-vect-loop.cc | 10 +++++++---
 gcc/tree-vect-slp.cc  | 11 ++++++-----
 gcc/tree-vectorizer.h | 19 +------------------
 3 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index b8e155b90f81..df89edac036d 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -4984,9 +4984,13 @@ vect_estimate_min_profitable_iters (loop_vec_info 
loop_vinfo,
     }
 
   /* Complete the target-specific cost calculations.  */
-  finish_cost (loop_vinfo->vector_costs, loop_vinfo->scalar_costs,
-              &vec_prologue_cost, &vec_inside_cost, &vec_epilogue_cost,
-              suggested_unroll_factor);
+  loop_vinfo->vector_costs->finish_cost (loop_vinfo->scalar_costs);
+  vec_prologue_cost = loop_vinfo->vector_costs->prologue_cost ();
+  vec_inside_cost = loop_vinfo->vector_costs->body_cost ();
+  vec_epilogue_cost = loop_vinfo->vector_costs->epilogue_cost ();
+  if (suggested_unroll_factor)
+    *suggested_unroll_factor
+      = loop_vinfo->vector_costs->suggested_unroll_factor ();
 
   if (suggested_unroll_factor && *suggested_unroll_factor > 1
       && LOOP_VINFO_MAX_VECT_FACTOR (loop_vinfo) != MAX_VECTORIZATION_FACTOR
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index a7f064bb0edf..21fd4c8dc09e 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -8859,9 +8859,8 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo,
        }
       while (si < li_scalar_costs.length ()
             && li_scalar_costs[si].first == sl);
-      unsigned dummy;
-      finish_cost (scalar_target_cost_data, nullptr,
-                  &dummy, &scalar_cost, &dummy);
+      scalar_target_cost_data->finish_cost (nullptr);
+      scalar_cost = scalar_target_cost_data->body_cost ();
 
       /* Complete the target-specific vector cost calculation.  */
       class vector_costs *vect_target_cost_data = init_cost (bb_vinfo, false);
@@ -8872,8 +8871,10 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo,
        }
       while (vi < li_vector_costs.length ()
             && li_vector_costs[vi].first == vl);
-      finish_cost (vect_target_cost_data, scalar_target_cost_data,
-                  &vec_prologue_cost, &vec_inside_cost, &vec_epilogue_cost);
+      vect_target_cost_data->finish_cost (scalar_target_cost_data);
+      vec_prologue_cost = vect_target_cost_data->prologue_cost ();
+      vec_inside_cost = vect_target_cost_data->body_cost ();
+      vec_epilogue_cost = vect_target_cost_data->epilogue_cost ();
       delete scalar_target_cost_data;
       delete vect_target_cost_data;
 
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index b51771f836ca..24227a69d4ac 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -1897,7 +1897,7 @@ extern void dump_stmt_cost (FILE *, int, enum 
vect_cost_for_stmt,
                            stmt_vec_info, slp_tree, tree, int, unsigned,
                            enum vect_cost_model_location);
 
-/* Alias targetm.vectorize.add_stmt_cost.  */
+/* Dump and add costs.  */
 
 inline unsigned
 add_stmt_cost (vector_costs *costs, int count,
@@ -1923,8 +1923,6 @@ add_stmt_cost (vector_costs *costs, int count, enum 
vect_cost_for_stmt kind,
   return add_stmt_cost (costs, count, kind, NULL, NULL, NULL_TREE, 0, where);
 }
 
-/* Alias targetm.vectorize.add_stmt_cost.  */
-
 inline unsigned
 add_stmt_cost (vector_costs *costs, stmt_info_for_cost *i)
 {
@@ -1932,21 +1930,6 @@ add_stmt_cost (vector_costs *costs, stmt_info_for_cost 
*i)
                        i->vectype, i->misalign, i->where);
 }
 
-/* Alias targetm.vectorize.finish_cost.  */
-
-inline void
-finish_cost (vector_costs *costs, const vector_costs *scalar_costs,
-            unsigned *prologue_cost, unsigned *body_cost,
-            unsigned *epilogue_cost, unsigned *suggested_unroll_factor = NULL)
-{
-  costs->finish_cost (scalar_costs);
-  *prologue_cost = costs->prologue_cost ();
-  *body_cost = costs->body_cost ();
-  *epilogue_cost = costs->epilogue_cost ();
-  if (suggested_unroll_factor)
-    *suggested_unroll_factor = costs->suggested_unroll_factor ();
-}
-
 inline void
 add_stmt_costs (vector_costs *costs, stmt_vector_for_cost *cost_vec)
 {

Reply via email to