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.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        * 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  | 17 ++++++++---------
 gcc/tree-vect-stmts.cc |  2 +-
 gcc/tree-vectorizer.h  | 26 ++++----------------------
 3 files changed, 13 insertions(+), 32 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 0b5f484810c..d659749225a 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6759,8 +6759,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);
@@ -6863,12 +6862,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))
@@ -6894,7 +6893,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);
     }
 
@@ -7914,7 +7913,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);
@@ -8093,7 +8092,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);
 
@@ -9153,7 +9152,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.  */
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 07291dfea41..01fc46cd246 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -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);
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 46d192e0bc8..6e75c3dc017 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -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.  */
 
-- 
2.51.0

Reply via email to