mirror of git://gcc.gnu.org/git/gcc.git
Move computation of SLP_TREE_NUMBER_OF_VEC_STMTS
Previously SLP_TREE_NUMBER_OF_VEC_STMTS was calculated while scheduling an SLP tree after analysis, but sometimes it can be useful to know the value during analysis too. This patch moves the calculation to vect_slp_analyze_node_operations instead. 2017-09-18 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree-vectorizer.h (vect_slp_analyze_operations): Replace parameters with a vec_info *. * tree-vect-loop.c (vect_analyze_loop_operations): Update call accordingly. * tree-vect-slp.c (vect_slp_analyze_node_operations): Add vec_info * parameter. Set SLP_TREE_NUMBER_OF_VEC_STMTS here rather than in vect_schedule_slp_instance. (vect_slp_analyze_operations): Replace parameters with a vec_info *. Update call to vect_slp_analyze_node_operations. Simplify return value. (vect_slp_analyze_bb_1): Update call accordingly. (vect_schedule_slp_instance): Remove vectorization_factor parameter. Don't calculate SLP_TREE_NUMBER_OF_VEC_STMTS here. (vect_schedule_slp): Update call accordingly. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252935
This commit is contained in:
parent
ac8936b467
commit
8b7e9dba2b
|
|
@ -1,3 +1,22 @@
|
||||||
|
2017-09-18 Richard Sandiford <richard.sandiford@linaro.org>
|
||||||
|
Alan Hayward <alan.hayward@arm.com>
|
||||||
|
David Sherwood <david.sherwood@arm.com>
|
||||||
|
|
||||||
|
* tree-vectorizer.h (vect_slp_analyze_operations): Replace parameters
|
||||||
|
with a vec_info *.
|
||||||
|
* tree-vect-loop.c (vect_analyze_loop_operations): Update call
|
||||||
|
accordingly.
|
||||||
|
* tree-vect-slp.c (vect_slp_analyze_node_operations): Add vec_info *
|
||||||
|
parameter. Set SLP_TREE_NUMBER_OF_VEC_STMTS here rather than in
|
||||||
|
vect_schedule_slp_instance.
|
||||||
|
(vect_slp_analyze_operations): Replace parameters with a vec_info *.
|
||||||
|
Update call to vect_slp_analyze_node_operations. Simplify return
|
||||||
|
value.
|
||||||
|
(vect_slp_analyze_bb_1): Update call accordingly.
|
||||||
|
(vect_schedule_slp_instance): Remove vectorization_factor parameter.
|
||||||
|
Don't calculate SLP_TREE_NUMBER_OF_VEC_STMTS here.
|
||||||
|
(vect_schedule_slp): Update call accordingly.
|
||||||
|
|
||||||
2017-09-18 Richard Sandiford <richard.sandiford@linaro.org>
|
2017-09-18 Richard Sandiford <richard.sandiford@linaro.org>
|
||||||
Alan Hayward <alan.hayward@arm.com>
|
Alan Hayward <alan.hayward@arm.com>
|
||||||
David Sherwood <david.sherwood@arm.com>
|
David Sherwood <david.sherwood@arm.com>
|
||||||
|
|
|
||||||
|
|
@ -2031,8 +2031,7 @@ start_over:
|
||||||
remove unsupported SLP instances which makes the above
|
remove unsupported SLP instances which makes the above
|
||||||
SLP kind detection invalid. */
|
SLP kind detection invalid. */
|
||||||
unsigned old_size = LOOP_VINFO_SLP_INSTANCES (loop_vinfo).length ();
|
unsigned old_size = LOOP_VINFO_SLP_INSTANCES (loop_vinfo).length ();
|
||||||
vect_slp_analyze_operations (LOOP_VINFO_SLP_INSTANCES (loop_vinfo),
|
vect_slp_analyze_operations (loop_vinfo);
|
||||||
LOOP_VINFO_TARGET_COST_DATA (loop_vinfo));
|
|
||||||
if (LOOP_VINFO_SLP_INSTANCES (loop_vinfo).length () != old_size)
|
if (LOOP_VINFO_SLP_INSTANCES (loop_vinfo).length () != old_size)
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2525,11 +2525,14 @@ _bb_vec_info::~_bb_vec_info ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Analyze statements contained in SLP tree node after recursively analyzing
|
/* Analyze statements contained in SLP tree NODE after recursively analyzing
|
||||||
the subtree. Return TRUE if the operations are supported. */
|
the subtree. NODE_INSTANCE contains NODE and VINFO contains INSTANCE.
|
||||||
|
|
||||||
|
Return true if the operations are supported. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
vect_slp_analyze_node_operations (slp_tree node, slp_instance node_instance)
|
vect_slp_analyze_node_operations (vec_info *vinfo, slp_tree node,
|
||||||
|
slp_instance node_instance)
|
||||||
{
|
{
|
||||||
bool dummy;
|
bool dummy;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
@ -2540,7 +2543,7 @@ vect_slp_analyze_node_operations (slp_tree node, slp_instance node_instance)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
|
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
|
||||||
if (!vect_slp_analyze_node_operations (child, node_instance))
|
if (!vect_slp_analyze_node_operations (vinfo, child, node_instance))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stmt = SLP_TREE_SCALAR_STMTS (node)[0];
|
stmt = SLP_TREE_SCALAR_STMTS (node)[0];
|
||||||
|
|
@ -2592,6 +2595,29 @@ vect_slp_analyze_node_operations (slp_tree node, slp_instance node_instance)
|
||||||
STMT_VINFO_VECTYPE (vinfo_for_stmt (sstmt)) = vectype;
|
STMT_VINFO_VECTYPE (vinfo_for_stmt (sstmt)) = vectype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Calculate the number of vector statements to be created for the
|
||||||
|
scalar stmts in this node. For SLP reductions it is equal to the
|
||||||
|
number of vector statements in the children (which has already been
|
||||||
|
calculated by the recursive call). Otherwise it is the number of
|
||||||
|
scalar elements in one scalar iteration (GROUP_SIZE) multiplied by
|
||||||
|
VF divided by the number of elements in a vector. */
|
||||||
|
if (GROUP_FIRST_ELEMENT (stmt_info)
|
||||||
|
&& !STMT_VINFO_GROUPED_ACCESS (stmt_info))
|
||||||
|
SLP_TREE_NUMBER_OF_VEC_STMTS (node)
|
||||||
|
= SLP_TREE_NUMBER_OF_VEC_STMTS (SLP_TREE_CHILDREN (node)[0]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int vf;
|
||||||
|
if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo))
|
||||||
|
vf = loop_vinfo->vectorization_factor;
|
||||||
|
else
|
||||||
|
vf = 1;
|
||||||
|
unsigned int group_size = SLP_INSTANCE_GROUP_SIZE (node_instance);
|
||||||
|
tree vectype = STMT_VINFO_VECTYPE (stmt_info);
|
||||||
|
SLP_TREE_NUMBER_OF_VEC_STMTS (node)
|
||||||
|
= vf * group_size / TYPE_VECTOR_SUBPARTS (vectype);
|
||||||
|
}
|
||||||
|
|
||||||
/* Push SLP node def-type to stmt operands. */
|
/* Push SLP node def-type to stmt operands. */
|
||||||
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), j, child)
|
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), j, child)
|
||||||
if (SLP_TREE_DEF_TYPE (child) != vect_internal_def)
|
if (SLP_TREE_DEF_TYPE (child) != vect_internal_def)
|
||||||
|
|
@ -2610,11 +2636,11 @@ vect_slp_analyze_node_operations (slp_tree node, slp_instance node_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Analyze statements in SLP instances of the basic block. Return TRUE if the
|
/* Analyze statements in SLP instances of VINFO. Return true if the
|
||||||
operations are supported. */
|
operations are supported. */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
vect_slp_analyze_operations (vec<slp_instance> slp_instances, void *data)
|
vect_slp_analyze_operations (vec_info *vinfo)
|
||||||
{
|
{
|
||||||
slp_instance instance;
|
slp_instance instance;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -2623,9 +2649,10 @@ vect_slp_analyze_operations (vec<slp_instance> slp_instances, void *data)
|
||||||
dump_printf_loc (MSG_NOTE, vect_location,
|
dump_printf_loc (MSG_NOTE, vect_location,
|
||||||
"=== vect_slp_analyze_operations ===\n");
|
"=== vect_slp_analyze_operations ===\n");
|
||||||
|
|
||||||
for (i = 0; slp_instances.iterate (i, &instance); )
|
for (i = 0; vinfo->slp_instances.iterate (i, &instance); )
|
||||||
{
|
{
|
||||||
if (!vect_slp_analyze_node_operations (SLP_INSTANCE_TREE (instance),
|
if (!vect_slp_analyze_node_operations (vinfo,
|
||||||
|
SLP_INSTANCE_TREE (instance),
|
||||||
instance))
|
instance))
|
||||||
{
|
{
|
||||||
dump_printf_loc (MSG_NOTE, vect_location,
|
dump_printf_loc (MSG_NOTE, vect_location,
|
||||||
|
|
@ -2634,20 +2661,17 @@ vect_slp_analyze_operations (vec<slp_instance> slp_instances, void *data)
|
||||||
SLP_TREE_SCALAR_STMTS
|
SLP_TREE_SCALAR_STMTS
|
||||||
(SLP_INSTANCE_TREE (instance))[0], 0);
|
(SLP_INSTANCE_TREE (instance))[0], 0);
|
||||||
vect_free_slp_instance (instance);
|
vect_free_slp_instance (instance);
|
||||||
slp_instances.ordered_remove (i);
|
vinfo->slp_instances.ordered_remove (i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Compute the costs of the SLP instance. */
|
/* Compute the costs of the SLP instance. */
|
||||||
vect_analyze_slp_cost (instance, data);
|
vect_analyze_slp_cost (instance, vinfo->target_cost_data);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!slp_instances.length ())
|
return !vinfo->slp_instances.is_empty ();
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2921,8 +2945,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vect_slp_analyze_operations (BB_VINFO_SLP_INSTANCES (bb_vinfo),
|
if (!vect_slp_analyze_operations (bb_vinfo))
|
||||||
BB_VINFO_TARGET_COST_DATA (bb_vinfo)))
|
|
||||||
{
|
{
|
||||||
if (dump_enabled_p ())
|
if (dump_enabled_p ())
|
||||||
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
|
||||||
|
|
@ -3676,14 +3699,13 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
|
||||||
/* Vectorize SLP instance tree in postorder. */
|
/* Vectorize SLP instance tree in postorder. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
vect_schedule_slp_instance (slp_tree node, slp_instance instance,
|
vect_schedule_slp_instance (slp_tree node, slp_instance instance)
|
||||||
unsigned int vectorization_factor)
|
|
||||||
{
|
{
|
||||||
gimple *stmt;
|
gimple *stmt;
|
||||||
bool grouped_store, is_store;
|
bool grouped_store, is_store;
|
||||||
gimple_stmt_iterator si;
|
gimple_stmt_iterator si;
|
||||||
stmt_vec_info stmt_info;
|
stmt_vec_info stmt_info;
|
||||||
unsigned int vec_stmts_size, nunits, group_size;
|
unsigned int group_size;
|
||||||
tree vectype;
|
tree vectype;
|
||||||
int i, j;
|
int i, j;
|
||||||
slp_tree child;
|
slp_tree child;
|
||||||
|
|
@ -3692,7 +3714,7 @@ vect_schedule_slp_instance (slp_tree node, slp_instance instance,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
|
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
|
||||||
vect_schedule_slp_instance (child, instance, vectorization_factor);
|
vect_schedule_slp_instance (child, instance);
|
||||||
|
|
||||||
/* Push SLP node def-type to stmts. */
|
/* Push SLP node def-type to stmts. */
|
||||||
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
|
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
|
||||||
|
|
@ -3705,27 +3727,10 @@ vect_schedule_slp_instance (slp_tree node, slp_instance instance,
|
||||||
|
|
||||||
/* VECTYPE is the type of the destination. */
|
/* VECTYPE is the type of the destination. */
|
||||||
vectype = STMT_VINFO_VECTYPE (stmt_info);
|
vectype = STMT_VINFO_VECTYPE (stmt_info);
|
||||||
nunits = (unsigned int) TYPE_VECTOR_SUBPARTS (vectype);
|
|
||||||
group_size = SLP_INSTANCE_GROUP_SIZE (instance);
|
group_size = SLP_INSTANCE_GROUP_SIZE (instance);
|
||||||
|
|
||||||
/* For each SLP instance calculate number of vector stmts to be created
|
|
||||||
for the scalar stmts in each node of the SLP tree. Number of vector
|
|
||||||
elements in one vector iteration is the number of scalar elements in
|
|
||||||
one scalar iteration (GROUP_SIZE) multiplied by VF divided by vector
|
|
||||||
size.
|
|
||||||
Unless this is a SLP reduction in which case the number of vector
|
|
||||||
stmts is equal to the number of vector stmts of the children. */
|
|
||||||
if (GROUP_FIRST_ELEMENT (stmt_info)
|
|
||||||
&& !STMT_VINFO_GROUPED_ACCESS (stmt_info))
|
|
||||||
vec_stmts_size = SLP_TREE_NUMBER_OF_VEC_STMTS (SLP_TREE_CHILDREN (node)[0]);
|
|
||||||
else
|
|
||||||
vec_stmts_size = (vectorization_factor * group_size) / nunits;
|
|
||||||
|
|
||||||
if (!SLP_TREE_VEC_STMTS (node).exists ())
|
if (!SLP_TREE_VEC_STMTS (node).exists ())
|
||||||
{
|
SLP_TREE_VEC_STMTS (node).create (SLP_TREE_NUMBER_OF_VEC_STMTS (node));
|
||||||
SLP_TREE_VEC_STMTS (node).create (vec_stmts_size);
|
|
||||||
SLP_TREE_NUMBER_OF_VEC_STMTS (node) = vec_stmts_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dump_enabled_p ())
|
if (dump_enabled_p ())
|
||||||
{
|
{
|
||||||
|
|
@ -3874,20 +3879,15 @@ vect_schedule_slp (vec_info *vinfo)
|
||||||
{
|
{
|
||||||
vec<slp_instance> slp_instances;
|
vec<slp_instance> slp_instances;
|
||||||
slp_instance instance;
|
slp_instance instance;
|
||||||
unsigned int i, vf;
|
unsigned int i;
|
||||||
bool is_store = false;
|
bool is_store = false;
|
||||||
|
|
||||||
slp_instances = vinfo->slp_instances;
|
slp_instances = vinfo->slp_instances;
|
||||||
if (is_a <loop_vec_info> (vinfo))
|
|
||||||
vf = as_a <loop_vec_info> (vinfo)->vectorization_factor;
|
|
||||||
else
|
|
||||||
vf = 1;
|
|
||||||
|
|
||||||
FOR_EACH_VEC_ELT (slp_instances, i, instance)
|
FOR_EACH_VEC_ELT (slp_instances, i, instance)
|
||||||
{
|
{
|
||||||
/* Schedule the tree of INSTANCE. */
|
/* Schedule the tree of INSTANCE. */
|
||||||
is_store = vect_schedule_slp_instance (SLP_INSTANCE_TREE (instance),
|
is_store = vect_schedule_slp_instance (SLP_INSTANCE_TREE (instance),
|
||||||
instance, vf);
|
instance);
|
||||||
if (dump_enabled_p ())
|
if (dump_enabled_p ())
|
||||||
dump_printf_loc (MSG_NOTE, vect_location,
|
dump_printf_loc (MSG_NOTE, vect_location,
|
||||||
"vectorizing stmts using SLP.\n");
|
"vectorizing stmts using SLP.\n");
|
||||||
|
|
|
||||||
|
|
@ -1246,8 +1246,7 @@ extern void vect_free_slp_instance (slp_instance);
|
||||||
extern bool vect_transform_slp_perm_load (slp_tree, vec<tree> ,
|
extern bool vect_transform_slp_perm_load (slp_tree, vec<tree> ,
|
||||||
gimple_stmt_iterator *, int,
|
gimple_stmt_iterator *, int,
|
||||||
slp_instance, bool, unsigned *);
|
slp_instance, bool, unsigned *);
|
||||||
extern bool vect_slp_analyze_operations (vec<slp_instance> slp_instances,
|
extern bool vect_slp_analyze_operations (vec_info *);
|
||||||
void *);
|
|
||||||
extern bool vect_schedule_slp (vec_info *);
|
extern bool vect_schedule_slp (vec_info *);
|
||||||
extern bool vect_analyze_slp (vec_info *, unsigned);
|
extern bool vect_analyze_slp (vec_info *, unsigned);
|
||||||
extern bool vect_make_slp_decision (loop_vec_info);
|
extern bool vect_make_slp_decision (loop_vec_info);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue