]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Cleanup vect_get_num_copies API
authorRichard Biener <rguenther@suse.de>
Thu, 18 Sep 2025 12:19:40 +0000 (14:19 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 19 Sep 2025 07:35:02 +0000 (09:35 +0200)
The following removes the dual non-SLP/SLP API in favor of only
handling SLP.  This also removes the possibility to override
vectype of a SLP node with an inconsistent one while still using
the SLP nodes number of lanes.  This requires adjustment of
a few places where such inconsistencies happened.

* tree-vectorizer.h (vect_get_num_copies): Remove unused
overload.  Remove defaulted vectype argument and always
use the vector type of the SLP node.
* tree-vect-loop.cc (vect_reduction_update_partial_vector_usage):
Adjust.
(vectorizable_lane_reducing): Likewise.
(vect_transform_reduction): Likewise.
(vectorizable_nonlinear_induction): Likewise.
* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Likewise.

gcc/tree-vect-loop.cc
gcc/tree-vect-stmts.cc
gcc/tree-vectorizer.h

index 5bed19f10f8a040a5560e44c6f70e35403ba0717..18360375e2974b8540df4ddf945d7397925d4c54 100644 (file)
@@ -6753,8 +6753,7 @@ vect_reduction_update_partial_vector_usage (loop_vec_info loop_vinfo,
                        = get_masked_reduction_fn (reduc_fn, vectype_in);
       vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
       vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo);
-      unsigned nvectors = vect_get_num_copies (loop_vinfo, slp_node,
-                                              vectype_in);
+      unsigned nvectors = vect_get_num_copies (loop_vinfo, slp_node);
 
       if (mask_reduc_fn == IFN_MASK_LEN_FOLD_LEFT_PLUS)
        vect_record_loop_len (loop_vinfo, lens, nvectors, vectype_in, 1);
@@ -6857,12 +6856,12 @@ vectorizable_lane_reducing (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
        return false;
     }
 
-  tree vectype_in = SLP_TREE_VECTYPE (SLP_TREE_CHILDREN (slp_node)[0]);
+  slp_tree node_in = SLP_TREE_CHILDREN (slp_node)[0];
+  tree vectype_in = SLP_TREE_VECTYPE (node_in);
   gcc_assert (vectype_in);
 
   /* Compute number of effective vector statements for costing.  */
-  unsigned int ncopies_for_cost = vect_get_num_copies (loop_vinfo, slp_node,
-                                                      vectype_in);
+  unsigned int ncopies_for_cost = vect_get_num_copies (loop_vinfo, node_in);
   gcc_assert (ncopies_for_cost >= 1);
 
   if (vect_is_emulated_mixed_dot_prod (slp_node))
@@ -6888,7 +6887,7 @@ vectorizable_lane_reducing (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
     {
       enum tree_code code = gimple_assign_rhs_code (stmt);
       vect_reduction_update_partial_vector_usage (loop_vinfo, reduc_info,
-                                                 slp_node, code, type,
+                                                 node_in, code, type,
                                                  vectype_in);
     }
 
@@ -7908,7 +7907,7 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
   int reduc_index = SLP_TREE_REDUC_IDX (slp_node);
   tree vectype_in = SLP_TREE_VECTYPE (SLP_TREE_CHILDREN (slp_node)[0]);
 
-  vec_num = vect_get_num_copies (loop_vinfo, slp_node, vectype_in);
+  vec_num = vect_get_num_copies (loop_vinfo, SLP_TREE_CHILDREN (slp_node)[0]);
 
   code_helper code = canonicalize_code (op.code, op.type);
   internal_fn cond_fn = get_conditional_internal_fn (code, op.type);
@@ -8087,7 +8086,7 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
       gcc_assert (reduc_vectype_in);
 
       unsigned effec_reduc_ncopies
-       = vect_get_num_copies (loop_vinfo, slp_node, reduc_vectype_in);
+       = vect_get_num_copies (loop_vinfo, SLP_TREE_CHILDREN (slp_node)[0]);
 
       gcc_assert (effec_ncopies <= effec_reduc_ncopies);
 
@@ -9147,7 +9146,7 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
 
   gcc_assert (induction_type > vect_step_op_add);
 
-  ncopies = vect_get_num_copies (loop_vinfo, slp_node, vectype);
+  ncopies = vect_get_num_copies (loop_vinfo, slp_node);
   gcc_assert (ncopies >= 1);
 
   /* FORNOW. Only handle nonlinear induction in the same loop.  */
index 07291dfea415bf2a2206bebe0db7aa6333ea29d8..01fc46cd246a901cee72d51c9b1731104a369afd 100644 (file)
@@ -1459,7 +1459,7 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype,
          scalar_mask = def;
       }
 
-  unsigned int nvectors = vect_get_num_copies (loop_vinfo, slp_node, vectype);
+  unsigned int nvectors = vect_get_num_copies (loop_vinfo, slp_node);
   vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
   vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo);
   machine_mode vecmode = TYPE_MODE (vectype);
index d6ff23252d872f6a201812d3516a0e5370da47ca..07c67be157ed3f2b9fe87ed8bb56ffad96efc62f 100644 (file)
@@ -2296,13 +2296,10 @@ vect_get_num_vectors (poly_uint64 nunits, tree vectype)
 }
 
 /* Return the number of vectors in the context of vectorization region VINFO,
-   needed for a group of statements, whose size is specified by lanes of NODE,
-   if NULL, it is 1.  The statements are supposed to be interleaved together
-   with no gap, and all operate on vectors of type VECTYPE, if NULL, the
-   vectype of NODE is used.  */
+   needed for a group of statements and a vector type as specified by NODE.  */
 
 inline unsigned int
-vect_get_num_copies (vec_info *vinfo, slp_tree node, tree vectype = NULL)
+vect_get_num_copies (vec_info *vinfo, slp_tree node)
 {
   poly_uint64 vf;
 
@@ -2311,27 +2308,12 @@ vect_get_num_copies (vec_info *vinfo, slp_tree node, tree vectype = NULL)
   else
     vf = 1;
 
-  if (node)
-    {
-      vf *= SLP_TREE_LANES (node);
-      if (!vectype)
-       vectype = SLP_TREE_VECTYPE (node);
-    }
+  vf *= SLP_TREE_LANES (node);
+  tree vectype = SLP_TREE_VECTYPE (node);
 
   return vect_get_num_vectors (vf, vectype);
 }
 
-/* Return the number of copies needed for loop vectorization when
-   a statement operates on vectors of type VECTYPE.  This is the
-   vectorization factor divided by the number of elements in
-   VECTYPE and is always known at compile time.  */
-
-inline unsigned int
-vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype)
-{
-  return vect_get_num_copies (loop_vinfo, NULL, vectype);
-}
-
 /* Update maximum unit count *MAX_NUNITS so that it accounts for
    NUNITS.  *MAX_NUNITS can be 1 if we haven't yet recorded anything.  */