mirror of git://gcc.gnu.org/git/gcc.git
[09/46] Add vec_info::lookup_single_use
This patch adds a helper function for seeing whether there is a single user of an SSA name, and whether that user has a stmt_vec_info. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vectorizer.h (vec_info::lookup_single_use): Declare. * tree-vectorizer.c (vec_info::lookup_single_use): New function. * tree-vect-loop.c (vectorizable_reduction): Use it instead of a single_imm_use-based sequence. * tree-vect-stmts.c (supportable_widening_operation): Likewise. From-SVN: r263124
This commit is contained in:
parent
c98d05955b
commit
0d0a4e205b
|
|
@ -1,3 +1,11 @@
|
||||||
|
2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
|
||||||
|
|
||||||
|
* tree-vectorizer.h (vec_info::lookup_single_use): Declare.
|
||||||
|
* tree-vectorizer.c (vec_info::lookup_single_use): New function.
|
||||||
|
* tree-vect-loop.c (vectorizable_reduction): Use it instead of
|
||||||
|
a single_imm_use-based sequence.
|
||||||
|
* tree-vect-stmts.c (supportable_widening_operation): Likewise.
|
||||||
|
|
||||||
2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
|
2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
|
||||||
|
|
||||||
* tree-vectorizer.h (vec_info::lookup_def): Declare.
|
* tree-vectorizer.h (vec_info::lookup_def): Declare.
|
||||||
|
|
|
||||||
|
|
@ -6138,6 +6138,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
|
||||||
|
|
||||||
if (gimple_code (stmt) == GIMPLE_PHI)
|
if (gimple_code (stmt) == GIMPLE_PHI)
|
||||||
{
|
{
|
||||||
|
tree phi_result = gimple_phi_result (stmt);
|
||||||
/* Analysis is fully done on the reduction stmt invocation. */
|
/* Analysis is fully done on the reduction stmt invocation. */
|
||||||
if (! vec_stmt)
|
if (! vec_stmt)
|
||||||
{
|
{
|
||||||
|
|
@ -6158,7 +6159,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
|
||||||
if (STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (reduc_stmt)))
|
if (STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (reduc_stmt)))
|
||||||
reduc_stmt = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (reduc_stmt));
|
reduc_stmt = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (reduc_stmt));
|
||||||
|
|
||||||
if (STMT_VINFO_VEC_REDUCTION_TYPE (vinfo_for_stmt (reduc_stmt))
|
stmt_vec_info reduc_stmt_info = vinfo_for_stmt (reduc_stmt);
|
||||||
|
if (STMT_VINFO_VEC_REDUCTION_TYPE (reduc_stmt_info)
|
||||||
== EXTRACT_LAST_REDUCTION)
|
== EXTRACT_LAST_REDUCTION)
|
||||||
/* Leave the scalar phi in place. */
|
/* Leave the scalar phi in place. */
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -6185,15 +6187,12 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
|
||||||
else
|
else
|
||||||
ncopies = vect_get_num_copies (loop_vinfo, vectype_in);
|
ncopies = vect_get_num_copies (loop_vinfo, vectype_in);
|
||||||
|
|
||||||
use_operand_p use_p;
|
stmt_vec_info use_stmt_info;
|
||||||
gimple *use_stmt;
|
|
||||||
if (ncopies > 1
|
if (ncopies > 1
|
||||||
&& (STMT_VINFO_RELEVANT (vinfo_for_stmt (reduc_stmt))
|
&& STMT_VINFO_RELEVANT (reduc_stmt_info) <= vect_used_only_live
|
||||||
<= vect_used_only_live)
|
&& (use_stmt_info = loop_vinfo->lookup_single_use (phi_result))
|
||||||
&& single_imm_use (gimple_phi_result (stmt), &use_p, &use_stmt)
|
&& (use_stmt_info == reduc_stmt_info
|
||||||
&& (use_stmt == reduc_stmt
|
|| STMT_VINFO_RELATED_STMT (use_stmt_info) == reduc_stmt))
|
||||||
|| (STMT_VINFO_RELATED_STMT (vinfo_for_stmt (use_stmt))
|
|
||||||
== reduc_stmt)))
|
|
||||||
single_defuse_cycle = true;
|
single_defuse_cycle = true;
|
||||||
|
|
||||||
/* Create the destination vector */
|
/* Create the destination vector */
|
||||||
|
|
@ -6955,13 +6954,13 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
|
||||||
This only works when we see both the reduction PHI and its only consumer
|
This only works when we see both the reduction PHI and its only consumer
|
||||||
in vectorizable_reduction and there are no intermediate stmts
|
in vectorizable_reduction and there are no intermediate stmts
|
||||||
participating. */
|
participating. */
|
||||||
use_operand_p use_p;
|
stmt_vec_info use_stmt_info;
|
||||||
gimple *use_stmt;
|
tree reduc_phi_result = gimple_phi_result (reduc_def_stmt);
|
||||||
if (ncopies > 1
|
if (ncopies > 1
|
||||||
&& (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live)
|
&& (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live)
|
||||||
&& single_imm_use (gimple_phi_result (reduc_def_stmt), &use_p, &use_stmt)
|
&& (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result))
|
||||||
&& (use_stmt == stmt
|
&& (use_stmt_info == stmt_info
|
||||||
|| STMT_VINFO_RELATED_STMT (vinfo_for_stmt (use_stmt)) == stmt))
|
|| STMT_VINFO_RELATED_STMT (use_stmt_info) == stmt))
|
||||||
{
|
{
|
||||||
single_defuse_cycle = true;
|
single_defuse_cycle = true;
|
||||||
epilog_copies = 1;
|
epilog_copies = 1;
|
||||||
|
|
|
||||||
|
|
@ -10310,14 +10310,11 @@ supportable_widening_operation (enum tree_code code, gimple *stmt,
|
||||||
same operation. One such an example is s += a * b, where elements
|
same operation. One such an example is s += a * b, where elements
|
||||||
in a and b cannot be reordered. Here we check if the vector defined
|
in a and b cannot be reordered. Here we check if the vector defined
|
||||||
by STMT is only directly used in the reduction statement. */
|
by STMT is only directly used in the reduction statement. */
|
||||||
tree lhs = gimple_assign_lhs (stmt);
|
tree lhs = gimple_assign_lhs (stmt);
|
||||||
use_operand_p dummy;
|
stmt_vec_info use_stmt_info = loop_info->lookup_single_use (lhs);
|
||||||
gimple *use_stmt;
|
if (use_stmt_info
|
||||||
stmt_vec_info use_stmt_info = NULL;
|
&& STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def)
|
||||||
if (single_imm_use (lhs, &dummy, &use_stmt)
|
return true;
|
||||||
&& (use_stmt_info = vinfo_for_stmt (use_stmt))
|
|
||||||
&& STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def)
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
c1 = VEC_WIDEN_MULT_LO_EXPR;
|
c1 = VEC_WIDEN_MULT_LO_EXPR;
|
||||||
c2 = VEC_WIDEN_MULT_HI_EXPR;
|
c2 = VEC_WIDEN_MULT_HI_EXPR;
|
||||||
|
|
|
||||||
|
|
@ -548,6 +548,20 @@ vec_info::lookup_def (tree name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See whether there is a single non-debug statement that uses LHS and
|
||||||
|
whether that statement has an associated stmt_vec_info. Return the
|
||||||
|
stmt_vec_info if so, otherwise return null. */
|
||||||
|
|
||||||
|
stmt_vec_info
|
||||||
|
vec_info::lookup_single_use (tree lhs)
|
||||||
|
{
|
||||||
|
use_operand_p dummy;
|
||||||
|
gimple *use_stmt;
|
||||||
|
if (single_imm_use (lhs, &dummy, &use_stmt))
|
||||||
|
return lookup_stmt (use_stmt);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* A helper function to free scev and LOOP niter information, as well as
|
/* A helper function to free scev and LOOP niter information, as well as
|
||||||
clear loop constraint LOOP_C_FINITE. */
|
clear loop constraint LOOP_C_FINITE. */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,7 @@ struct vec_info {
|
||||||
stmt_vec_info add_stmt (gimple *);
|
stmt_vec_info add_stmt (gimple *);
|
||||||
stmt_vec_info lookup_stmt (gimple *);
|
stmt_vec_info lookup_stmt (gimple *);
|
||||||
stmt_vec_info lookup_def (tree);
|
stmt_vec_info lookup_def (tree);
|
||||||
|
stmt_vec_info lookup_single_use (tree);
|
||||||
|
|
||||||
/* The type of vectorization. */
|
/* The type of vectorization. */
|
||||||
vec_kind kind;
|
vec_kind kind;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue