This removes the max_nunits field from slp_tree and internal APIs
as it is now unused.
* tree-vectorizer.h (_slp_tree::max_nunits): Remove.
(vect_update_max_nunits): Likewise.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Adjust.
(vect_record_max_nunits): Rename to ...
(vect_record_vectype): ... this and adjust.
(vect_build_slp_tree_1): Drop max_nunits argument and adjust.
(vect_build_slp_tree_2): Likewise.
(vect_build_slp_tree): Likewise.
(vect_build_slp_store_interleaving): Likewise.
(vect_print_slp_tree): Adjust.
(optimize_load_redistribution_1): Likewise.
(vect_build_slp_instance): Likewise.
(vect_analyze_slp_reduc_chain): Likewise.
(vect_analyze_slp_reduction): Likewise.
(vect_analyze_slp_reduction_group): Likewise.
(vect_analyze_slp_instance): Likewise.
(vect_lower_load_permutations): Likewise.
---
gcc/tree-vect-slp.cc | 109 ++++++++----------------------------------
gcc/tree-vectorizer.h | 25 ----------
2 files changed, 21 insertions(+), 113 deletions(-)
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 505fe1dbed4..c4db4de9a9c 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -131,7 +131,6 @@ _slp_tree::_slp_tree ()
this->cycle_info.reduc_idx = -1;
SLP_TREE_REF_COUNT (this) = 1;
this->failed = NULL;
- this->max_nunits = 1;
this->lanes = 0;
SLP_TREE_TYPE (this) = undef_vec_info_type;
this->data = NULL;
@@ -1099,14 +1098,11 @@ compatible_calls_p (gcall *call1, gcall *call2, bool
allow_two_operators)
/* A subroutine of vect_build_slp_tree for checking VECTYPE, which is the
caller's attempt to find the vector type in STMT_INFO with the narrowest
element type. Return true if VECTYPE is nonnull and if it is valid
- for STMT_INFO. When returning true, update MAX_NUNITS to reflect the
- number of units in VECTYPE. GROUP_SIZE and MAX_NUNITS are as for
- vect_build_slp_tree. */
+ for STMT_INFO. GROUP_SIZE is as for vect_build_slp_tree. */
static bool
-vect_record_max_nunits (vec_info *vinfo, stmt_vec_info stmt_info,
- unsigned int group_size,
- tree vectype, poly_uint64 *max_nunits)
+vect_record_vectype (vec_info *vinfo, stmt_vec_info stmt_info,
+ unsigned int group_size, tree vectype)
{
if (!vectype)
{
@@ -1119,7 +1115,7 @@ vect_record_max_nunits (vec_info *vinfo, stmt_vec_info
stmt_info,
}
/* If populating the vector type requires unrolling then fail
- before adjusting *max_nunits for basic-block vectorization. */
+ for basic-block vectorization. */
if (is_a <bb_vec_info> (vinfo)
&& !multiple_p (group_size, TYPE_VECTOR_SUBPARTS (vectype)))
{
@@ -1131,8 +1127,6 @@ vect_record_max_nunits (vec_info *vinfo, stmt_vec_info
stmt_info,
return false;
}
- /* In case of multiple types we need to detect the smallest type. */
- vect_update_max_nunits (max_nunits, vectype);
return true;
}
@@ -1152,8 +1146,7 @@ vect_record_max_nunits (vec_info *vinfo, stmt_vec_info
stmt_info,
static bool
vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
- vec<stmt_vec_info> stmts,
- poly_uint64 *max_nunits, bool *matches,
+ vec<stmt_vec_info> stmts, bool *matches,
bool *two_operators, tree *node_vectype)
{
unsigned int group_size = stmts.length ();
@@ -1194,8 +1187,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char
*swap,
as if nunits was not an issue. This allows splitting of groups
to happen. */
if (nunits_vectype
- && !vect_record_max_nunits (vinfo, first_stmt_info, group_size,
- nunits_vectype, max_nunits))
+ && !vect_record_vectype (vinfo, first_stmt_info, group_size,
+ nunits_vectype))
{
gcc_assert (is_a <bb_vec_info> (vinfo));
maybe_soft_fail = true;
@@ -1899,14 +1892,12 @@ static unsigned least_upthread_swappable_op_distance =
-1U;
static slp_tree
vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
vec<stmt_vec_info> stmts,
- poly_uint64 *max_nunits,
bool *matches, unsigned *limit, unsigned *tree_size,
scalar_stmts_to_slp_tree_map_t *bst_map);
static slp_tree
vect_build_slp_tree (vec_info *vinfo,
vec<stmt_vec_info> stmts,
- poly_uint64 *max_nunits,
bool *matches, unsigned *limit, unsigned *tree_size,
scalar_stmts_to_slp_tree_map_t *bst_map)
{
@@ -1920,7 +1911,6 @@ vect_build_slp_tree (vec_info *vinfo,
if (!(*leader)->failed)
{
SLP_TREE_REF_COUNT (*leader)++;
- vect_update_max_nunits (max_nunits, (*leader)->max_nunits);
stmts.release ();
return *leader;
}
@@ -1954,9 +1944,7 @@ vect_build_slp_tree (vec_info *vinfo,
dump_printf_loc (MSG_NOTE, vect_location,
"starting SLP discovery for node %p\n", (void *) res);
- poly_uint64 this_max_nunits = 1;
slp_tree res_ = vect_build_slp_tree_2 (vinfo, res, stmts,
- &this_max_nunits,
matches, limit, tree_size, bst_map);
if (!res_)
{
@@ -1985,8 +1973,6 @@ vect_build_slp_tree (vec_info *vinfo,
"SLP discovery for node %p succeeded\n",
(void *) res);
gcc_assert (res_ == res);
- res->max_nunits = this_max_nunits;
- vect_update_max_nunits (max_nunits, this_max_nunits);
/* Keep a reference for the bst_map use. */
SLP_TREE_REF_COUNT (res)++;
}
@@ -2043,13 +2029,11 @@ vect_slp_build_two_operator_nodes (slp_tree perm, tree
vectype,
static slp_tree
vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
vec<stmt_vec_info> stmts,
- poly_uint64 *max_nunits,
bool *matches, unsigned *limit, unsigned *tree_size,
scalar_stmts_to_slp_tree_map_t *bst_map)
{
unsigned int group_size = stmts.length ();
unsigned nops, i, this_tree_size = 0;
- poly_uint64 this_max_nunits = *max_nunits;
matches[0] = false;
@@ -2073,8 +2057,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
tree scalar_type = TREE_TYPE (PHI_RESULT (stmt));
tree vectype = get_vectype_for_scalar_type (vinfo, scalar_type,
group_size);
- if (!vect_record_max_nunits (vinfo, stmt_info, group_size, vectype,
- max_nunits))
+ if (!vect_record_vectype (vinfo, stmt_info, group_size, vectype))
return NULL;
vect_def_type def_type = STMT_VINFO_DEF_TYPE (stmt_info);
@@ -2126,8 +2109,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
bool two_operators = false;
unsigned char *swap = XALLOCAVEC (unsigned char, group_size);
tree vectype = NULL_TREE;
- if (!vect_build_slp_tree_1 (vinfo, swap, stmts,
- &this_max_nunits, matches, &two_operators,
+ if (!vect_build_slp_tree_1 (vinfo, swap, stmts, matches, &two_operators,
&vectype))
return NULL;
@@ -2139,7 +2121,6 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
gcc_assert (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)));
else
{
- *max_nunits = this_max_nunits;
(*tree_size)++;
node = vect_create_new_slp_node (node, stmts, 0);
SLP_TREE_VECTYPE (node) = vectype;
@@ -2223,8 +2204,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
}
bool *matches2 = XALLOCAVEC (bool, dr_group_size);
slp_tree unperm_load
- = vect_build_slp_tree (vinfo, stmts2,
- &this_max_nunits, matches2, limit,
+ = vect_build_slp_tree (vinfo, stmts2, matches2, limit,
&this_tree_size, bst_map);
/* When we are able to do the full masked load emit that
followed by 'node' being the desired final permutation. */
@@ -2529,7 +2509,6 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
else
op_stmts.quick_push (NULL);
child = vect_build_slp_tree (vinfo, op_stmts,
- &this_max_nunits,
matches, limit,
&this_tree_size, bst_map);
/* ??? We're likely getting too many fatal mismatches
@@ -2685,7 +2664,6 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
children[i] = child;
}
*tree_size += this_tree_size + 1;
- *max_nunits = this_max_nunits;
while (!chains.is_empty ())
chains.pop ().release ();
return node;
@@ -2968,7 +2946,6 @@ out:
def_stmts2.create (1);
def_stmts2.quick_push (oprnd_info->def_stmts[0]);
child = vect_build_slp_tree (vinfo, def_stmts2,
- &this_max_nunits,
matches, limit,
&this_tree_size, bst_map);
if (child)
@@ -2986,7 +2963,6 @@ out:
.quick_push (std::make_pair (0u, 0u));
}
SLP_TREE_CHILDREN (pnode).quick_push (child);
- pnode->max_nunits = child->max_nunits;
children.safe_push (pnode);
oprnd_info->def_stmts = vNULL;
continue;
@@ -3041,7 +3017,6 @@ out:
else if (least_upthread_swappable_op_distance != -1U)
least_upthread_swappable_op_distance++;
child = vect_build_slp_tree (vinfo, oprnd_info->def_stmts,
- &this_max_nunits,
matches, limit,
&this_tree_size, bst_map);
least_upthread_swappable_op_distance = old_swap_distance;
@@ -3103,7 +3078,6 @@ out:
/* And try again with scratch 'matches' ... */
bool *tem = XALLOCAVEC (bool, group_size);
if ((child = vect_build_slp_tree (vinfo, oprnd_info->def_stmts,
- &this_max_nunits,
tem, limit,
&this_tree_size, bst_map)) != NULL)
{
@@ -3215,7 +3189,6 @@ fail:
}
*tree_size += this_tree_size + 1;
- *max_nunits = this_max_nunits;
if (two_operators)
{
@@ -3364,14 +3337,12 @@ vect_print_slp_tree (dump_flags_t dump_kind,
dump_location_t loc,
dump_metadata_t metadata (dump_kind, loc.get_impl_location ());
dump_user_location_t user_loc = loc.get_user_location ();
dump_printf_loc (metadata, user_loc,
- "node%s %p (max_nunits=" HOST_WIDE_INT_PRINT_UNSIGNED
- ", refcnt=%u)",
+ "node%s %p (refcnt=%u)",
SLP_TREE_DEF_TYPE (node) == vect_external_def
? " (external)"
: (SLP_TREE_DEF_TYPE (node) == vect_constant_def
? " (constant)"
: ""), (void *) node,
- estimated_poly_value (node->max_nunits),
SLP_TREE_REF_COUNT (node));
if (SLP_TREE_VECTYPE (node))
dump_printf (metadata, " %T", SLP_TREE_VECTYPE (node));
@@ -3830,9 +3801,8 @@ optimize_load_redistribution_1
(scalar_stmts_to_slp_tree_map_t *bst_map,
(void *) root);
bool *matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0, limit = 1;
- node = vect_build_slp_tree (vinfo, stmts, &max_nunits,
+ node = vect_build_slp_tree (vinfo, stmts,
matches, &limit, &tree_size, bst_map);
if (!node)
stmts.release ();
@@ -4014,15 +3984,13 @@ vect_analyze_slp_instance (vec_info *vinfo,
static slp_tree
vect_build_slp_store_interleaving (vec<slp_tree> &rhs_nodes,
- vec<stmt_vec_info> &scalar_stmts,
- poly_uint64 max_nunits)
+ vec<stmt_vec_info> &scalar_stmts)
{
unsigned int group_size = scalar_stmts.length ();
slp_tree node = vect_create_new_slp_node (scalar_stmts,
SLP_TREE_CHILDREN
(rhs_nodes[0]).length ());
SLP_TREE_VECTYPE (node) = SLP_TREE_VECTYPE (rhs_nodes[0]);
- node->max_nunits = max_nunits;
for (unsigned l = 0;
l < SLP_TREE_CHILDREN (rhs_nodes[0]).length (); ++l)
{
@@ -4032,7 +4000,6 @@ vect_build_slp_store_interleaving (vec<slp_tree>
&rhs_nodes,
SLP_TREE_CHILDREN (node).quick_push (perm);
SLP_TREE_LANE_PERMUTATION (perm).create (group_size);
SLP_TREE_VECTYPE (perm) = SLP_TREE_VECTYPE (node);
- perm->max_nunits = max_nunits;
SLP_TREE_LANES (perm) = group_size;
SLP_TREE_REPRESENTATIVE (perm) = NULL;
for (unsigned j = 0; j < rhs_nodes.length (); ++j)
@@ -4086,7 +4053,6 @@ vect_build_slp_store_interleaving (vec<slp_tree>
&rhs_nodes,
SLP_TREE_LANES (permab) = n;
SLP_TREE_LANE_PERMUTATION (permab).create (n);
SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm);
- permab->max_nunits = max_nunits;
/* ??? Should be NULL but that's not expected. */
SLP_TREE_REPRESENTATIVE (permab) = SLP_TREE_REPRESENTATIVE (perm);
SLP_TREE_CHILDREN (permab).quick_push (a);
@@ -4157,7 +4123,6 @@ vect_build_slp_store_interleaving (vec<slp_tree>
&rhs_nodes,
SLP_TREE_LANES (permab) = n;
SLP_TREE_LANE_PERMUTATION (permab).create (n);
SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm);
- permab->max_nunits = max_nunits;
/* ??? Should be NULL but that's not expected. */
SLP_TREE_REPRESENTATIVE (permab) = SLP_TREE_REPRESENTATIVE (perm);
SLP_TREE_CHILDREN (permab).quick_push (a);
@@ -4249,7 +4214,6 @@ vect_build_slp_instance (vec_info *vinfo,
/* Build the tree for the SLP instance. */
unsigned int group_size = scalar_stmts.length ();
bool *matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0;
slp_tree node = NULL;
@@ -4259,17 +4223,10 @@ vect_build_slp_instance (vec_info *vinfo,
matches[1] = false;
}
else
- node = vect_build_slp_tree (vinfo, scalar_stmts,
- &max_nunits, matches, limit,
+ node = vect_build_slp_tree (vinfo, scalar_stmts, matches, limit,
&tree_size, bst_map);
if (node != NULL)
{
- /* Calculate the unrolling factor based on the smallest type. */
- poly_uint64 unrolling_factor
- = calculate_unrolling_factor (max_nunits, group_size);
- gcc_assert (!is_a <bb_vec_info> (vinfo)
- || known_eq (unrolling_factor, 1U));
-
/* Create a new SLP instance. */
slp_instance new_instance = XNEW (class _slp_instance);
SLP_INSTANCE_TREE (new_instance) = node;
@@ -4552,10 +4509,8 @@ vect_analyze_slp_reduc_chain (loop_vec_info vinfo,
unsigned int group_size = scalar_stmts.length ();
bool *matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0;
- slp_tree node = vect_build_slp_tree (vinfo, scalar_stmts,
- &max_nunits, matches, limit,
+ slp_tree node = vect_build_slp_tree (vinfo, scalar_stmts, matches, limit,
&tree_size, bst_map);
if (!node)
{
@@ -4695,15 +4650,13 @@ vect_analyze_slp_reduc_chain (loop_vec_info vinfo,
/* Build the tree for the SLP instance. */
unsigned int group_size = scalar_stmts.length ();
bool *matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0;
/* ??? We need this only for SLP discovery. */
for (unsigned i = 0; i < scalar_stmts.length (); ++i)
REDUC_GROUP_FIRST_ELEMENT (scalar_stmts[i]) = scalar_stmts[0];
- slp_tree node = vect_build_slp_tree (vinfo, scalar_stmts,
- &max_nunits, matches, limit,
+ slp_tree node = vect_build_slp_tree (vinfo, scalar_stmts, matches, limit,
&tree_size, bst_map);
for (unsigned i = 0; i < scalar_stmts.length (); ++i)
@@ -4843,11 +4796,9 @@ vect_analyze_slp_reduction (loop_vec_info vinfo,
/* Build the tree for the SLP instance. */
unsigned int group_size = scalar_stmts.length ();
bool *matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0;
- slp_tree node = vect_build_slp_tree (vinfo, scalar_stmts,
- &max_nunits, matches, limit,
+ slp_tree node = vect_build_slp_tree (vinfo, scalar_stmts, matches, limit,
&tree_size, bst_map);
if (node != NULL)
{
@@ -4915,10 +4866,8 @@ vect_analyze_slp_reduction_group (loop_vec_info
loop_vinfo,
return false;
if (!matches)
matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0;
- slp_tree node = vect_build_slp_tree (loop_vinfo, scalar_stmts,
- &max_nunits, matches, limit,
+ slp_tree node = vect_build_slp_tree (loop_vinfo, scalar_stmts, matches,
limit,
&tree_size, bst_map);
if (!node)
return false;
@@ -5133,7 +5082,6 @@ vect_analyze_slp_instance (vec_info *vinfo,
/* Build the tree for the SLP instance. */
unsigned int group_size = scalar_stmts.length ();
bool *matches = XALLOCAVEC (bool, group_size);
- poly_uint64 max_nunits = 1;
unsigned tree_size = 0;
unsigned i;
@@ -5144,17 +5092,10 @@ vect_analyze_slp_instance (vec_info *vinfo,
matches[1] = false;
}
else
- node = vect_build_slp_tree (vinfo, scalar_stmts,
- &max_nunits, matches, limit,
+ node = vect_build_slp_tree (vinfo, scalar_stmts, matches, limit,
&tree_size, bst_map);
if (node != NULL)
{
- /* Calculate the unrolling factor based on the smallest type. */
- poly_uint64 unrolling_factor
- = calculate_unrolling_factor (max_nunits, group_size);
- gcc_assert (!is_a <bb_vec_info> (vinfo)
- || known_eq (unrolling_factor, 1U));
-
/* Create a new SLP instance. */
slp_instance new_instance = XNEW (class _slp_instance);
SLP_INSTANCE_TREE (new_instance) = node;
@@ -5295,7 +5236,6 @@ vect_analyze_slp_instance (vec_info *vinfo,
/* Analyze the stored values and pinch them together with
a permute node so we can preserve the whole store group. */
auto_vec<slp_tree> rhs_nodes;
- poly_uint64 max_nunits = 1;
unsigned int rhs_common_nlanes = 0;
unsigned int start = 0, end = i;
@@ -5306,14 +5246,11 @@ vect_analyze_slp_instance (vec_info *vinfo,
substmts.create (end - start);
for (unsigned j = start; j < end; ++j)
substmts.quick_push (scalar_stmts[j]);
- max_nunits = 1;
node = vect_build_slp_tree (vinfo, substmts,
- &max_nunits,
matches, limit, &tree_size, bst_map);
if (node)
{
rhs_nodes.safe_push (node);
- vect_update_max_nunits (&max_nunits, node->max_nunits);
if (start == 0)
rhs_common_nlanes = SLP_TREE_LANES (node);
else if (rhs_common_nlanes != SLP_TREE_LANES (node))
@@ -5377,7 +5314,6 @@ vect_analyze_slp_instance (vec_info *vinfo,
SLP_TREE_CHILDREN
(rhs_nodes[0]).length ());
SLP_TREE_VECTYPE (node) = SLP_TREE_VECTYPE (rhs_nodes[0]);
- node->max_nunits = max_nunits;
node->ldst_lanes = true;
SLP_TREE_CHILDREN (node)
.reserve_exact (SLP_TREE_CHILDREN (rhs_nodes[0]).length ()
@@ -5394,8 +5330,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
child->refcnt++;
}
else
- node = vect_build_slp_store_interleaving (rhs_nodes, scalar_stmts,
- max_nunits);
+ node = vect_build_slp_store_interleaving (rhs_nodes, scalar_stmts);
while (!rhs_nodes.is_empty ())
vect_free_slp_tree (rhs_nodes.pop ());
@@ -5675,12 +5610,10 @@ vect_lower_load_permutations (loop_vec_info loop_vinfo,
}
for (unsigned i = 0; i < DR_GROUP_GAP (first); ++i)
stmts.quick_push (NULL);
- poly_uint64 max_nunits = 1;
bool *matches = XALLOCAVEC (bool, group_lanes);
unsigned limit = 1;
unsigned tree_size = 0;
- slp_tree l0 = vect_build_slp_tree (loop_vinfo, stmts,
- &max_nunits, matches, &limit,
+ slp_tree l0 = vect_build_slp_tree (loop_vinfo, stmts, matches, &limit,
&tree_size, bst_map);
gcc_assert (!SLP_TREE_LOAD_PERMUTATION (l0).exists ());
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 35fb7afab83..9cf6741e19c 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -368,9 +368,6 @@ struct _slp_tree {
/* Reference count in the SLP graph. */
unsigned int refcnt;
- /* The maximum number of vector elements for the subtree rooted
- at this node. */
- poly_uint64 max_nunits;
/* The DEF type of this node. */
enum vect_def_type def_type;
/* The number of scalar lanes produced by this node. */
@@ -2364,28 +2361,6 @@ vect_get_num_copies (vec_info *vinfo, slp_tree node)
return vect_get_num_vectors (vf, 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. */
-
-inline void
-vect_update_max_nunits (poly_uint64 *max_nunits, poly_uint64 nunits)
-{
- /* All unit counts have the form vec_info::vector_size * X for some
- rational X, so two unit sizes must have a common multiple.
- Everything is a multiple of the initial value of 1. */
- *max_nunits = force_common_multiple (*max_nunits, nunits);
-}
-
-/* Update maximum unit count *MAX_NUNITS so that it accounts for
- the number of units in vector type VECTYPE. *MAX_NUNITS can be 1
- if we haven't yet recorded any vector types. */
-
-inline void
-vect_update_max_nunits (poly_uint64 *max_nunits, tree vectype)
-{
- vect_update_max_nunits (max_nunits, TYPE_VECTOR_SUBPARTS (vectype));
-}
-
/* Return the vectorization factor that should be used for costing
purposes while vectorizing the loop described by LOOP_VINFO.
Pick a reasonable estimate if the vectorization factor isn't
--
2.51.0