[gcc r16-3967] Cleanup vect_get_num_copies API
Richard Biener
rguenth@gcc.gnu.org
Fri Sep 19 07:35:33 GMT 2025
https://gcc.gnu.org/g:11e09c9ad814c1aa23e87d78246d35eb5ba28d66
commit r16-3967-g11e09c9ad814c1aa23e87d78246d35eb5ba28d66
Author: Richard Biener <rguenther@suse.de>
Date: Thu Sep 18 14:19:40 2025 +0200
Cleanup vect_get_num_copies API
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.
Diff:
---
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 5bed19f10f8a..18360375e297 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -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. */
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 07291dfea415..01fc46cd246a 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 d6ff23252d87..07c67be157ed 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. */
More information about the Gcc-cvs
mailing list