commit g:1786be14e94bf1a7806b9dc09186f021737f0227 stops storing in
STMT_VINFO_VECTYPE the vectype of the current stmt being vectorized and instead
requires the use of SLP_TREE_VECTYPE for everything but data-refs.

However contrary to what the commit says not all usages of STMT_VINFO_VECTYPE
have been purged from vectorizable_* as the costing hooks which don't pass the
SLP tree as an agrument will extract vectype using STMT_VINFO_VECTYPE.

This results in no vector type being passed to the backends and results in a few
costing test failures in AArch64.

This commit replaces the last few cases I could find, all except for in
vectorizable_reduction when single_defuse_cycle where the stmt being costed is
not the representative of the PHI in the SLP tree but rather the out of tree
reduction statement.  So I've left that alone, but it does mean vectype is NULL.

Most likely this needs to use the overload where we pass an explicit vectype but
I wasn't sure so left it for now.

Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues and fixes some failing AArch64 cost-model tests.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

        PR target/121536
        * tree-vect-loop.cc (vectorizable_phi, vectorizable_recurr,
        vectorizable_nonlinear_induction, vectorizable_induction): Pass slp_node
        instead of stmt_info to record_stmt_cost.

---
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 
3b56f865ec7c3fdb8e9def37ec446a25086b4e28..006fe980172b5f89663e9d85e0dc9cbba93753bb
 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8678,7 +8678,7 @@ vectorizable_phi (vec_info *,
         favoring the vector path (but may pessimize it in some cases).  */
       if (gimple_phi_num_args (as_a <gphi *> (stmt_info->stmt)) > 1)
        record_stmt_cost (cost_vec, SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node),
-                         vector_stmt, stmt_info, vectype, 0, vect_body);
+                         vector_stmt, slp_node, vectype, 0, vect_body);
       SLP_TREE_TYPE (slp_node) = phi_info_type;
       return true;
     }
@@ -8860,7 +8860,7 @@ vectorizable_recurr (loop_vec_info loop_vinfo, 
stmt_vec_info stmt_info,
         represented and costed separately.  */
       unsigned prologue_cost = 0;
       unsigned inside_cost = record_stmt_cost (cost_vec, ncopies, vector_stmt,
-                                              stmt_info, 0, vect_body);
+                                              slp_node, 0, vect_body);
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
                         "vectorizable_recurr: inside_cost = %d, "
@@ -9403,7 +9403,7 @@ vectorizable_nonlinear_induction (loop_vec_info 
loop_vinfo,
       /* loop cost for vec_loop. Neg induction doesn't have any
         inside_cost.  */
       inside_cost = record_stmt_cost (cost_vec, ncopies, vector_stmt,
-                                     stmt_info, 0, vect_body);
+                                     slp_node, 0, vect_body);
 
       /* loop cost for vec_loop. Neg induction doesn't have any
         inside_cost.  */
@@ -9412,7 +9412,7 @@ vectorizable_nonlinear_induction (loop_vec_info 
loop_vinfo,
 
       /* prologue cost for vec_init and vec_step.  */
       prologue_cost = record_stmt_cost (cost_vec, 2, scalar_to_vec,
-                                       stmt_info, 0, vect_prologue);
+                                       slp_node, 0, vect_prologue);
 
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
@@ -9710,11 +9710,11 @@ vectorizable_induction (loop_vec_info loop_vinfo,
       /* loop cost for vec_loop.  */
       inside_cost = record_stmt_cost (cost_vec,
                                      SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node),
-                                     vector_stmt, stmt_info, 0, vect_body);
+                                     vector_stmt, slp_node, 0, vect_body);
       /* prologue cost for vec_init (if not nested) and step.  */
       prologue_cost = record_stmt_cost (cost_vec, 1 + !nested_in_vect_loop,
                                        scalar_to_vec,
-                                       stmt_info, 0, vect_prologue);
+                                       slp_node, 0, vect_prologue);
       if (dump_enabled_p ())
        dump_printf_loc (MSG_NOTE, vect_location,
                         "vect_model_induction_cost: inside_cost = %d, "


-- 
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3b56f865ec7c3fdb8e9def37ec446a25086b4e28..006fe980172b5f89663e9d85e0dc9cbba93753bb 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8678,7 +8678,7 @@ vectorizable_phi (vec_info *,
 	 favoring the vector path (but may pessimize it in some cases).  */
       if (gimple_phi_num_args (as_a <gphi *> (stmt_info->stmt)) > 1)
 	record_stmt_cost (cost_vec, SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node),
-			  vector_stmt, stmt_info, vectype, 0, vect_body);
+			  vector_stmt, slp_node, vectype, 0, vect_body);
       SLP_TREE_TYPE (slp_node) = phi_info_type;
       return true;
     }
@@ -8860,7 +8860,7 @@ vectorizable_recurr (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
 	 represented and costed separately.  */
       unsigned prologue_cost = 0;
       unsigned inside_cost = record_stmt_cost (cost_vec, ncopies, vector_stmt,
-					       stmt_info, 0, vect_body);
+					       slp_node, 0, vect_body);
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "vectorizable_recurr: inside_cost = %d, "
@@ -9403,7 +9403,7 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
       /* loop cost for vec_loop. Neg induction doesn't have any
 	 inside_cost.  */
       inside_cost = record_stmt_cost (cost_vec, ncopies, vector_stmt,
-				      stmt_info, 0, vect_body);
+				      slp_node, 0, vect_body);
 
       /* loop cost for vec_loop. Neg induction doesn't have any
 	 inside_cost.  */
@@ -9412,7 +9412,7 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
 
       /* prologue cost for vec_init and vec_step.  */
       prologue_cost = record_stmt_cost (cost_vec, 2, scalar_to_vec,
-					stmt_info, 0, vect_prologue);
+					slp_node, 0, vect_prologue);
 
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
@@ -9710,11 +9710,11 @@ vectorizable_induction (loop_vec_info loop_vinfo,
       /* loop cost for vec_loop.  */
       inside_cost = record_stmt_cost (cost_vec,
 				      SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node),
-				      vector_stmt, stmt_info, 0, vect_body);
+				      vector_stmt, slp_node, 0, vect_body);
       /* prologue cost for vec_init (if not nested) and step.  */
       prologue_cost = record_stmt_cost (cost_vec, 1 + !nested_in_vect_loop,
 					scalar_to_vec,
-					stmt_info, 0, vect_prologue);
+					slp_node, 0, vect_prologue);
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "vect_model_induction_cost: inside_cost = %d, "

Reply via email to