[v6,06/11] New parameter for vect_maybe_update_slp_op_vectype

Message ID 20251206165518.5449-7-chris.bazley@arm.com
State Superseded
Headers
Series Extend BB SLP vectorization to use predicated tails |

Commit Message

Christopher Bazley Dec. 6, 2025, 4:55 p.m. UTC
  Update all callers to pass a pointer to the vectorizer state
into this helper function. Its value is temporarily unused
but will be required for BB SLP with predicated tails.

gcc/ChangeLog:

	* tree-vect-loop.cc (vectorizable_lane_reducing): Pass
	loop_vinfo to vect_maybe_update_slp_op_vectype.
	(vectorizable_reduction): As above.
	(vectorizable_lc_phi): As above.
	(vectorizable_phi): Pass vinfo to
	vect_maybe_update_slp_op_vectype.
	(vectorizable_recurr): Pass loop_vinfo to
	vect_maybe_update_slp_op_vectype.
	(vectorizable_induction): As above.
	* tree-vect-slp.cc (vectorizable_slp_permutation_1): Pass vinfo
	to vect_maybe_update_slp_op_vectype.
	* tree-vect-stmts.cc (vectorizable_bswap): As above.
	(vectorizable_call): As above.
	(vectorizable_simd_clone_call): As above.
	(vectorizable_conversion): As above.
	(vectorizable_assignment): As above.
	(vectorizable_shift): As above.
	(vectorizable_operation): As above.
	(vectorizable_store): As above.
	(vectorizable_load): As above.
	(vectorizable_condition): As above.
	(vectorizable_comparison_1): As above.
	(vect_maybe_update_slp_op_vectype): Update definition to accept
	a parameter of type vec_info *.
	* tree-vectorizer.h (vect_maybe_update_slp_op_vectype): Update
	declaration to accept a parameter of type vec_info *.

---
 gcc/tree-vect-loop.cc  | 20 ++++++++-------
 gcc/tree-vect-slp.cc   |  2 +-
 gcc/tree-vect-stmts.cc | 57 ++++++++++++++++++++++--------------------
 gcc/tree-vectorizer.h  |  2 +-
 4 files changed, 43 insertions(+), 38 deletions(-)
  

Patch

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3ac264f0ce3..9164cef92da 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6800,7 +6800,7 @@  vectorizable_lane_reducing (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
 	    return false;
 	}
 
-      if (!vect_maybe_update_slp_op_vectype (slp_op, vectype))
+      if (!vect_maybe_update_slp_op_vectype (loop_vinfo, slp_op, vectype))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -6937,7 +6937,7 @@  vectorizable_reduction (loop_vec_info loop_vinfo,
       unsigned j;
       slp_tree child;
       FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (slp_node), j, child)
-	if (!vect_maybe_update_slp_op_vectype (child,
+	if (!vect_maybe_update_slp_op_vectype (loop_vinfo, child,
 					       SLP_TREE_VECTYPE (slp_node)))
 	  {
 	    if (dump_enabled_p ())
@@ -7055,7 +7055,7 @@  vectorizable_reduction (loop_vec_info loop_vinfo,
 		  vectype_op = get_vectype_for_scalar_type (loop_vinfo,
 							    type_op);
 		  if (!vectype_op
-		      || !vect_maybe_update_slp_op_vectype (op_node,
+		      || !vect_maybe_update_slp_op_vectype (loop_vinfo, op_node,
 							    vectype_op))
 		    return false;
 		}
@@ -7744,7 +7744,8 @@  vectorizable_reduction (loop_vec_info loop_vinfo,
 
   if (single_defuse_cycle || reduction_type == FOLD_LEFT_REDUCTION)
     for (i = 0; i < (int) op.num_ops; i++)
-      if (!vect_maybe_update_slp_op_vectype (slp_op[i], vectype_op[i]))
+      if (!vect_maybe_update_slp_op_vectype (loop_vinfo, slp_op[i],
+					     vectype_op[i]))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -8449,7 +8450,8 @@  vectorizable_lc_phi (loop_vec_info loop_vinfo,
 
   /* Deal with copies from externs or constants that disguise as
      loop-closed PHI nodes (PR97886).  */
-  if (!vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
+  if (!vect_maybe_update_slp_op_vectype (loop_vinfo,
+					 SLP_TREE_CHILDREN (slp_node)[0],
 					 SLP_TREE_VECTYPE (slp_node)))
     {
       if (dump_enabled_p ())
@@ -8525,7 +8527,7 @@  vectorizable_phi (bb_vec_info vinfo,
 			       "PHI node with unvectorized backedge def\n");
 	    return false;
 	  }
-	else if (!vect_maybe_update_slp_op_vectype (child, vectype))
+	else if (!vect_maybe_update_slp_op_vectype (vinfo, child, vectype))
 	  {
 	    if (dump_enabled_p ())
 	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -8714,7 +8716,7 @@  vectorizable_recurr (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
       unsigned j;
       slp_tree child;
       FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (slp_node), j, child)
-	if (!vect_maybe_update_slp_op_vectype (child, vectype))
+	if (!vect_maybe_update_slp_op_vectype (loop_vinfo, child, vectype))
 	  {
 	    if (dump_enabled_p ())
 	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -9591,8 +9593,8 @@  vectorizable_induction (loop_vec_info loop_vinfo,
       unsigned j;
       slp_tree child;
       FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (slp_node), j, child)
-	if (!vect_maybe_update_slp_op_vectype
-	    (child, SLP_TREE_VECTYPE (slp_node)))
+	if (!vect_maybe_update_slp_op_vectype (loop_vinfo, child,
+					       SLP_TREE_VECTYPE (slp_node)))
 	  {
 	    if (dump_enabled_p ())
 	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 3becf34c09b..d76b18dd7d9 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -11514,7 +11514,7 @@  vectorizable_slp_permutation_1 (vec_info *vinfo, gimple_stmt_iterator *gsi,
   FOR_EACH_VEC_ELT (children, i, child)
     {
       if ((SLP_TREE_DEF_TYPE (child) != vect_internal_def
-	   && !vect_maybe_update_slp_op_vectype (child, op_vectype))
+	   && !vect_maybe_update_slp_op_vectype (vinfo, child, op_vectype))
 	  || !types_compatible_p (SLP_TREE_VECTYPE (child), op_vectype)
 	  || !types_compatible_p (TREE_TYPE (vectype), TREE_TYPE (op_vectype)))
 	{
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 8ffdaacb5d2..44759a360e4 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -3458,7 +3458,7 @@  vectorizable_bswap (vec_info *vinfo,
 
   if (cost_vec)
     {
-      if (!vect_maybe_update_slp_op_vectype (slp_op[0], vectype_in))
+      if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op[0], vectype_in))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -3793,7 +3793,7 @@  vectorizable_call (vec_info *vinfo,
   if (cost_vec) /* transformation not required.  */
     {
       for (i = 0; i < nargs; ++i)
-	if (!vect_maybe_update_slp_op_vectype (slp_op[i],
+	if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op[i],
 					       vectypes[i]
 					       ? vectypes[i] : vectype_in))
 	  {
@@ -4486,7 +4486,8 @@  vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info,
   if (cost_vec) /* transformation not required.  */
     {
       for (unsigned i = 0; i < nargs; ++i)
-	if (!vect_maybe_update_slp_op_vectype (slp_op[i], arginfo[i].vectype))
+	if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op[i],
+					       arginfo[i].vectype))
 	  {
 	    if (dump_enabled_p ())
 	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5716,8 +5717,8 @@  vectorizable_conversion (vec_info *vinfo,
 
   if (cost_vec)		/* transformation not required.  */
     {
-      if (!vect_maybe_update_slp_op_vectype (slp_op0, vectype_in)
-	  || !vect_maybe_update_slp_op_vectype (slp_op1, vectype_in))
+      if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op0, vectype_in)
+	  || !vect_maybe_update_slp_op_vectype (vinfo, slp_op1, vectype_in))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -6070,7 +6071,7 @@  vectorizable_assignment (vec_info *vinfo,
 
   if (cost_vec) /* transformation not required.  */
     {
-      if (!vect_maybe_update_slp_op_vectype (slp_op, vectype_in))
+      if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op, vectype_in))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -6398,13 +6399,13 @@  vectorizable_shift (vec_info *vinfo,
 
   if (cost_vec) /* transformation not required.  */
     {
-      if (!vect_maybe_update_slp_op_vectype (slp_op0, vectype)
+      if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op0, vectype)
 	  || ((!scalar_shift_arg || dt[1] == vect_internal_def)
-	      && (!incompatible_op1_vectype_p
-		  || dt[1] == vect_constant_def)
-	      && !vect_maybe_update_slp_op_vectype
-			 (slp_op1,
-			  incompatible_op1_vectype_p ? vectype : op1_vectype)))
+	      && (!incompatible_op1_vectype_p || dt[1] == vect_constant_def)
+	      && !vect_maybe_update_slp_op_vectype (vinfo, slp_op1,
+						    incompatible_op1_vectype_p
+						      ? vectype
+						      : op1_vectype)))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -6829,9 +6830,9 @@  vectorizable_operation (vec_info *vinfo,
 	}
 
       /* Put types on constant and invariant SLP children.  */
-      if (!vect_maybe_update_slp_op_vectype (slp_op0, vectype)
-	  || !vect_maybe_update_slp_op_vectype (slp_op1, vectype)
-	  || !vect_maybe_update_slp_op_vectype (slp_op2, vectype))
+      if (!vect_maybe_update_slp_op_vectype (vinfo, slp_op0, vectype)
+	  || !vect_maybe_update_slp_op_vectype (vinfo, slp_op1, vectype)
+	  || !vect_maybe_update_slp_op_vectype (vinfo, slp_op2, vectype))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -8306,9 +8307,9 @@  vectorizable_store (vec_info *vinfo,
 					      vls_type, group_size, &ls,
 					      mask_node);
 
-      if (!vect_maybe_update_slp_op_vectype (op_node, vectype)
+      if (!vect_maybe_update_slp_op_vectype (vinfo, op_node, vectype)
 	  || (mask_node
-	      && !vect_maybe_update_slp_op_vectype (mask_node,
+	      && !vect_maybe_update_slp_op_vectype (vinfo, mask_node,
 						    mask_vectype)))
 	{
 	  if (dump_enabled_p ())
@@ -8735,7 +8736,7 @@  vectorizable_store (vec_info *vinfo,
 	   above only handles the mask and the first store operand node.  */
 	for (slp_tree child : SLP_TREE_CHILDREN (slp_node))
 	  if (child != mask_node
-	      && !vect_maybe_update_slp_op_vectype (child, vectype))
+	      && !vect_maybe_update_slp_op_vectype (vinfo, child, vectype))
 	    {
 	      if (dump_enabled_p ())
 		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -9900,7 +9901,7 @@  vectorizable_load (vec_info *vinfo,
   if (costing_p) /* transformation not required.  */
     {
       if (mask_node
-	  && !vect_maybe_update_slp_op_vectype (mask_node,
+	  && !vect_maybe_update_slp_op_vectype (vinfo, mask_node,
 						mask_vectype))
 	{
 	  if (dump_enabled_p ())
@@ -12236,13 +12237,14 @@  vectorizable_condition (vec_info *vinfo,
 		       || !expand_vec_cond_expr_p (vectype, vec_cmp_type))))
 	return false;
 
-      if (!vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
+      if (!vect_maybe_update_slp_op_vectype (vinfo,
+					     SLP_TREE_CHILDREN (slp_node)[0],
 					     comp_vectype)
 	  || (op_adjust == 1
-	      && !vect_maybe_update_slp_op_vectype
-			      (SLP_TREE_CHILDREN (slp_node)[1], comp_vectype))
-	  || !vect_maybe_update_slp_op_vectype (then_slp_node, vectype)
-	  || !vect_maybe_update_slp_op_vectype (else_slp_node, vectype))
+	      && !vect_maybe_update_slp_op_vectype (
+		vinfo, SLP_TREE_CHILDREN (slp_node)[1], comp_vectype))
+	  || !vect_maybe_update_slp_op_vectype (vinfo, then_slp_node, vectype)
+	  || !vect_maybe_update_slp_op_vectype (vinfo, else_slp_node, vectype))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -12683,8 +12685,8 @@  vectorizable_comparison_1 (vec_info *vinfo, tree vectype,
 	}
 
       /* Put types on constant and invariant SLP children.  */
-      if (!vect_maybe_update_slp_op_vectype (slp_rhs1, vectype)
-	  || !vect_maybe_update_slp_op_vectype (slp_rhs2, vectype))
+      if (!vect_maybe_update_slp_op_vectype (vinfo, slp_rhs1, vectype)
+	  || !vect_maybe_update_slp_op_vectype (vinfo, slp_rhs2, vectype))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -13864,7 +13866,7 @@  vect_is_simple_use (vec_info *vinfo, slp_tree slp_node,
    for example when conflicting vector types are present.  */
 
 bool
-vect_maybe_update_slp_op_vectype (slp_tree op, tree vectype)
+vect_maybe_update_slp_op_vectype (vec_info *vinfo, slp_tree op, tree vectype)
 {
   if (!op || SLP_TREE_DEF_TYPE (op) == vect_internal_def)
     return true;
@@ -13878,6 +13880,7 @@  vect_maybe_update_slp_op_vectype (slp_tree op, tree vectype)
       && SLP_TREE_DEF_TYPE (op) == vect_external_def
       && SLP_TREE_LANES (op) > 1)
     return false;
+  (void) vinfo; /* FORNOW */
   SLP_TREE_VECTYPE (op) = vectype;
   return true;
 }
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 1830c29819a..b66aca240f4 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2499,7 +2499,7 @@  extern bool vect_is_simple_use (vec_info *, slp_tree,
 				unsigned, tree *, slp_tree *,
 				enum vect_def_type *,
 				tree *, stmt_vec_info * = NULL);
-extern bool vect_maybe_update_slp_op_vectype (slp_tree, tree);
+extern bool vect_maybe_update_slp_op_vectype (vec_info *, slp_tree, tree);
 extern tree perm_mask_for_reverse (tree);
 extern bool supportable_widening_operation (vec_info*, code_helper,
 					    stmt_vec_info, tree, tree,