Commit 30c0d1e3 by Richard Biener Committed by Richard Biener

tree-vectorizer.h (_slp_tree::ops): New member.

2019-10-21  Richard Biener  <rguenther@suse.de>

	* tree-vectorizer.h (_slp_tree::ops): New member.
	(SLP_TREE_SCALAR_OPS): New.
	(vect_get_slp_defs): Adjust prototype.
	* tree-vect-slp.c (vect_free_slp_tree): Release
	SLP_TREE_SCALAR_OPS.
	(vect_create_new_slp_node): Initialize it.  New overload for
	initializing by an operands array.
	(_slp_oprnd_info::ops): New member.
	(vect_create_oprnd_info): Initialize it.
	(vect_free_oprnd_info): Release it.
	(vect_get_and_check_slp_defs): Populate the operands array.
	Do not swap operands in the IL when not necessary.
	(vect_build_slp_tree_2): Build SLP nodes for invariant operands.
	Record SLP_TREE_SCALAR_OPS for all invariant nodes.  Also
	swap operands in the operands array.  Do not swap operands in
	the IL.
	(vect_slp_rearrange_stmts): Re-arrange SLP_TREE_SCALAR_OPS as well.
	(vect_gather_slp_loads): Fix.
	(vect_detect_hybrid_slp_stmts): Likewise.
	(vect_slp_analyze_node_operations_1): Search for a internal
	def child for computing reduction SLP_TREE_NUMBER_OF_VEC_STMTS.
	(vect_slp_analyze_node_operations): Skip ops-only stmts for
	the def-type push/pop dance.
	(vect_get_constant_vectors): Compute number_of_vectors here.
	Use SLP_TREE_SCALAR_OPS and simplify greatly.
	(vect_get_slp_vect_defs): Use gimple_get_lhs also for PHIs.
	(vect_get_slp_defs): Simplify greatly.
	* tree-vect-loop.c (vectorize_fold_left_reduction): Simplify.
	(vect_transform_reduction): Likewise.
	* tree-vect-stmts.c (vect_get_vec_defs): Simplify.
	(vectorizable_call): Likewise.
	(vectorizable_operation): Likewise.
	(vectorizable_load): Likewise.
	(vectorizable_condition): Likewise.
	(vectorizable_comparison): Likewise.

From-SVN: r277241
parent ae7f3143
2019-10-21 Richard Biener <rguenther@suse.de>
* tree-vectorizer.h (_slp_tree::ops): New member.
(SLP_TREE_SCALAR_OPS): New.
(vect_get_slp_defs): Adjust prototype.
* tree-vect-slp.c (vect_free_slp_tree): Release
SLP_TREE_SCALAR_OPS.
(vect_create_new_slp_node): Initialize it. New overload for
initializing by an operands array.
(_slp_oprnd_info::ops): New member.
(vect_create_oprnd_info): Initialize it.
(vect_free_oprnd_info): Release it.
(vect_get_and_check_slp_defs): Populate the operands array.
Do not swap operands in the IL when not necessary.
(vect_build_slp_tree_2): Build SLP nodes for invariant operands.
Record SLP_TREE_SCALAR_OPS for all invariant nodes. Also
swap operands in the operands array. Do not swap operands in
the IL.
(vect_slp_rearrange_stmts): Re-arrange SLP_TREE_SCALAR_OPS as well.
(vect_gather_slp_loads): Fix.
(vect_detect_hybrid_slp_stmts): Likewise.
(vect_slp_analyze_node_operations_1): Search for a internal
def child for computing reduction SLP_TREE_NUMBER_OF_VEC_STMTS.
(vect_slp_analyze_node_operations): Skip ops-only stmts for
the def-type push/pop dance.
(vect_get_constant_vectors): Compute number_of_vectors here.
Use SLP_TREE_SCALAR_OPS and simplify greatly.
(vect_get_slp_vect_defs): Use gimple_get_lhs also for PHIs.
(vect_get_slp_defs): Simplify greatly.
* tree-vect-loop.c (vectorize_fold_left_reduction): Simplify.
(vect_transform_reduction): Likewise.
* tree-vect-stmts.c (vect_get_vec_defs): Simplify.
(vectorizable_call): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_load): Likewise.
(vectorizable_condition): Likewise.
(vectorizable_comparison): Likewise.
2019-10-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/92161
* tree-vect-loop.c (vect_analyze_loop_2): Reset stmts def-type
for reductions.
......@@ -5312,10 +5312,7 @@ vectorize_fold_left_reduction (stmt_vec_info stmt_info,
if (slp_node)
{
auto_vec<vec<tree> > vec_defs (2);
auto_vec<tree> sops(2);
sops.quick_push (ops[0]);
sops.quick_push (ops[1]);
vect_get_slp_defs (sops, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds0.safe_splice (vec_defs[1 - reduc_index]);
vec_defs[0].release ();
vec_defs[1].release ();
......@@ -6484,16 +6481,8 @@ vect_transform_reduction (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
{
/* Get vec defs for all the operands except the reduction index,
ensuring the ordering of the ops in the vector is kept. */
auto_vec<tree, 3> slp_ops;
auto_vec<vec<tree>, 3> vec_defs;
slp_ops.quick_push (ops[0]);
slp_ops.quick_push (ops[1]);
if (op_type == ternary_op)
slp_ops.quick_push (ops[2]);
vect_get_slp_defs (slp_ops, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds0.safe_splice (vec_defs[0]);
vec_defs[0].release ();
vec_oprnds1.safe_splice (vec_defs[1]);
......
......@@ -1726,16 +1726,8 @@ vect_get_vec_defs (tree op0, tree op1, stmt_vec_info stmt_info,
{
if (slp_node)
{
int nops = (op1 == NULL_TREE) ? 1 : 2;
auto_vec<tree> ops (nops);
auto_vec<vec<tree> > vec_defs (nops);
ops.quick_push (op0);
if (op1)
ops.quick_push (op1);
vect_get_slp_defs (ops, slp_node, &vec_defs);
auto_vec<vec<tree> > vec_defs (SLP_TREE_CHILDREN (slp_node).length ());
vect_get_slp_defs (slp_node, &vec_defs, op1 ? 2 : 1);
*vec_oprnds0 = vec_defs[0];
if (op1)
*vec_oprnds1 = vec_defs[1];
......@@ -3473,9 +3465,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
auto_vec<vec<tree> > vec_defs (nargs);
vec<tree> vec_oprnds0;
for (i = 0; i < nargs; i++)
vargs[i] = gimple_call_arg (stmt, i);
vect_get_slp_defs (vargs, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds0 = vec_defs[0];
/* Arguments are ready. Create the new vector stmt. */
......@@ -3647,9 +3637,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
auto_vec<vec<tree> > vec_defs (nargs);
vec<tree> vec_oprnds0;
for (i = 0; i < nargs; i++)
vargs.quick_push (gimple_call_arg (stmt, i));
vect_get_slp_defs (vargs, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds0 = vec_defs[0];
/* Arguments are ready. Create the new vector stmt. */
......@@ -6195,12 +6183,8 @@ vectorizable_operation (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
{
if (slp_node)
{
auto_vec<tree> ops(3);
ops.quick_push (op0);
ops.quick_push (op1);
ops.quick_push (op2);
auto_vec<vec<tree> > vec_defs(3);
vect_get_slp_defs (ops, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds0 = vec_defs[0];
vec_oprnds1 = vec_defs[1];
vec_oprnds2 = vec_defs[2];
......@@ -9271,10 +9255,8 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
{
if (slp_node)
{
auto_vec<tree> ops (1);
auto_vec<vec<tree> > vec_defs (1);
ops.quick_push (mask);
vect_get_slp_defs (ops, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_mask = vec_defs[0][0];
}
else
......@@ -10046,19 +10028,8 @@ vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
{
if (slp_node)
{
auto_vec<tree, 4> ops;
auto_vec<vec<tree>, 4> vec_defs;
if (masked)
ops.safe_push (cond_expr);
else
{
ops.safe_push (cond_expr0);
ops.safe_push (cond_expr1);
}
ops.safe_push (then_clause);
ops.safe_push (else_clause);
vect_get_slp_defs (ops, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds3 = vec_defs.pop ();
vec_oprnds2 = vec_defs.pop ();
if (!masked)
......@@ -10461,12 +10432,8 @@ vectorizable_comparison (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
{
if (slp_node)
{
auto_vec<tree, 2> ops;
auto_vec<vec<tree>, 2> vec_defs;
ops.safe_push (rhs1);
ops.safe_push (rhs2);
vect_get_slp_defs (ops, slp_node, &vec_defs);
vect_get_slp_defs (slp_node, &vec_defs);
vec_oprnds1 = vec_defs.pop ();
vec_oprnds0 = vec_defs.pop ();
if (swap_p)
......
......@@ -120,6 +120,8 @@ struct _slp_tree {
vec<slp_tree> children;
/* A group of scalar stmts to be vectorized together. */
vec<stmt_vec_info> stmts;
/* A group of scalar operands to be vectorized together. */
vec<tree> ops;
/* Load permutation relative to the stores, NULL if there is no
permutation. */
vec<unsigned> load_permutation;
......@@ -171,6 +173,7 @@ public:
#define SLP_TREE_CHILDREN(S) (S)->children
#define SLP_TREE_SCALAR_STMTS(S) (S)->stmts
#define SLP_TREE_SCALAR_OPS(S) (S)->ops
#define SLP_TREE_VEC_STMTS(S) (S)->vec_stmts
#define SLP_TREE_NUMBER_OF_VEC_STMTS(S) (S)->vec_stmts_size
#define SLP_TREE_LOAD_PERMUTATION(S) (S)->load_permutation
......@@ -1750,7 +1753,7 @@ extern void vect_schedule_slp (vec_info *);
extern opt_result vect_analyze_slp (vec_info *, unsigned);
extern bool vect_make_slp_decision (loop_vec_info);
extern void vect_detect_hybrid_slp (loop_vec_info);
extern void vect_get_slp_defs (vec<tree> , slp_tree, vec<vec<tree> > *);
extern void vect_get_slp_defs (slp_tree, vec<vec<tree> > *, unsigned n = -1U);
extern bool vect_slp_bb (basic_block);
extern stmt_vec_info vect_find_last_scalar_stmt_in_slp (slp_tree);
extern bool is_simple_and_all_uses_invariant (stmt_vec_info, loop_vec_info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment