From: Richard Biener Date: Thu, 4 Jun 2020 12:59:16 +0000 (+0200) Subject: add vect_get_slp_vect_def X-Git-Tag: upstream/12.2.0~16022 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b15369e2538086c95250ac57c56a4c2590f922f4;p=platform%2Fupstream%2Fgcc.git add vect_get_slp_vect_def This adds vect_get_slp_vect_def to get at a SLP nodes vectorized def, abstracting away the details. It also fixes one stray failure to use SLP_TREE_REPRESENTATIVE. 2020-05-04 Richard Biener * tree-vectorizer.h (vect_get_slp_vect_def): Declare. * tree-vect-loop.c (vect_create_epilog_for_reduction): Use it. * tree-vect-stmts.c (vect_transform_stmt): Likewise. (vect_is_simple_use): Use SLP_TREE_REPRESENTATIVE. * tree-vect-slp.c (vect_get_slp_vect_defs): Fold into single use ... (vect_get_slp_defs): ... here. (vect_get_slp_vect_def): New function. --- diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index e3fbf9f..f2c52ae 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -4719,7 +4719,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, for (unsigned i = 0; i < vec_num; i++) { if (slp_node) - def = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[i]->stmt); + def = vect_get_slp_vect_def (slp_node, i); else def = gimple_get_lhs (STMT_VINFO_VEC_STMT (rdef_info)->stmt); for (j = 0; j < ncopies; j++) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 65c49f5..1d26c31 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3660,23 +3660,17 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree op_node) SLP_TREE_VEC_DEFS (op_node).quick_push (vop); } +/* Get the Ith vectorized definition from SLP_NODE. */ -/* Get vectorized definitions from SLP_NODE that contains corresponding - vectorized def-stmts. */ - -static void -vect_get_slp_vect_defs (slp_tree slp_node, vec *vec_oprnds) +tree +vect_get_slp_vect_def (slp_tree slp_node, unsigned i) { - stmt_vec_info vec_def_stmt_info; - unsigned int i; - - gcc_assert (SLP_TREE_VEC_STMTS (slp_node).exists ()); - - FOR_EACH_VEC_ELT (SLP_TREE_VEC_STMTS (slp_node), i, vec_def_stmt_info) - vec_oprnds->quick_push (gimple_get_lhs (vec_def_stmt_info->stmt)); + if (SLP_TREE_VEC_STMTS (slp_node).exists ()) + return gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[i]->stmt); + else + return SLP_TREE_VEC_DEFS (slp_node)[i]; } - /* Get N vectorized definitions for SLP_NODE. */ void @@ -3696,7 +3690,12 @@ vect_get_slp_defs (vec_info *, node or we need to create them (for invariants and constants). */ vec_defs.create (SLP_TREE_NUMBER_OF_VEC_STMTS (child)); if (SLP_TREE_DEF_TYPE (child) == vect_internal_def) - vect_get_slp_vect_defs (child, &vec_defs); + { + unsigned j; + stmt_vec_info vec_def_stmt_info; + FOR_EACH_VEC_ELT (SLP_TREE_VEC_STMTS (child), j, vec_def_stmt_info) + vec_defs.quick_push (gimple_get_lhs (vec_def_stmt_info->stmt)); + } else vec_defs.splice (SLP_TREE_VEC_DEFS (child)); diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 4df1d90..c0be6ef 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -11385,7 +11385,7 @@ vect_transform_stmt (vec_info *vinfo, == SLP_TREE_VEC_STMTS (slp_node).length ()); for (unsigned i = 0; i < SLP_TREE_VEC_STMTS (phi_node).length (); ++i) add_phi_arg (as_a (SLP_TREE_VEC_STMTS (phi_node)[i]->stmt), - gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[i]->stmt), + vect_get_slp_vect_def (slp_node, i), e, gimple_phi_arg_location (phi, e->dest_idx)); } } @@ -11850,7 +11850,7 @@ vect_is_simple_use (vec_info *vinfo, stmt_vec_info stmt, slp_tree slp_node, slp_tree child = SLP_TREE_CHILDREN (slp_node)[operand]; *slp_def = child; if (SLP_TREE_DEF_TYPE (child) == vect_internal_def) - *op = gimple_get_lhs (SLP_TREE_SCALAR_STMTS (child)[0]->stmt); + *op = gimple_get_lhs (SLP_TREE_REPRESENTATIVE (child)->stmt); else { if (def_stmt_info_out) diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 1396da7..9bb82a5 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1753,6 +1753,7 @@ extern void vect_get_vec_defs_for_stmt_copy (vec_info *, extern tree vect_init_vector (vec_info *, stmt_vec_info, tree, tree, gimple_stmt_iterator *); extern tree vect_get_vec_def_for_stmt_copy (vec_info *, tree); +extern tree vect_get_slp_vect_def (slp_tree, unsigned); extern bool vect_transform_stmt (vec_info *, stmt_vec_info, gimple_stmt_iterator *, slp_tree, slp_instance);