aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2018-07-31 14:21:51 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-07-31 14:21:51 +0000
commit0d0a4e205bb6da84e9218c483acf7b13453f0698 (patch)
tree1ca4973bd7c74cc1e5bda94fe35cba4da262da40 /gcc/tree-vect-loop.c
parentc98d05955ba54fcdbae37f2a9e81b8cca6f1ca59 (diff)
downloadgcc-0d0a4e205bb6da84e9218c483acf7b13453f0698.zip
gcc-0d0a4e205bb6da84e9218c483acf7b13453f0698.tar.gz
gcc-0d0a4e205bb6da84e9218c483acf7b13453f0698.tar.bz2
[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
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 856c198..4fe3e1d 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -6138,6 +6138,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
if (gimple_code (stmt) == GIMPLE_PHI)
{
+ tree phi_result = gimple_phi_result (stmt);
/* Analysis is fully done on the reduction stmt invocation. */
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)))
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)
/* Leave the scalar phi in place. */
return true;
@@ -6185,15 +6187,12 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
else
ncopies = vect_get_num_copies (loop_vinfo, vectype_in);
- use_operand_p use_p;
- gimple *use_stmt;
+ stmt_vec_info use_stmt_info;
if (ncopies > 1
- && (STMT_VINFO_RELEVANT (vinfo_for_stmt (reduc_stmt))
- <= vect_used_only_live)
- && single_imm_use (gimple_phi_result (stmt), &use_p, &use_stmt)
- && (use_stmt == reduc_stmt
- || (STMT_VINFO_RELATED_STMT (vinfo_for_stmt (use_stmt))
- == reduc_stmt)))
+ && STMT_VINFO_RELEVANT (reduc_stmt_info) <= vect_used_only_live
+ && (use_stmt_info = loop_vinfo->lookup_single_use (phi_result))
+ && (use_stmt_info == reduc_stmt_info
+ || STMT_VINFO_RELATED_STMT (use_stmt_info) == reduc_stmt))
single_defuse_cycle = true;
/* 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
in vectorizable_reduction and there are no intermediate stmts
participating. */
- use_operand_p use_p;
- gimple *use_stmt;
+ stmt_vec_info use_stmt_info;
+ tree reduc_phi_result = gimple_phi_result (reduc_def_stmt);
if (ncopies > 1
&& (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live)
- && single_imm_use (gimple_phi_result (reduc_def_stmt), &use_p, &use_stmt)
- && (use_stmt == stmt
- || STMT_VINFO_RELATED_STMT (vinfo_for_stmt (use_stmt)) == stmt))
+ && (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result))
+ && (use_stmt_info == stmt_info
+ || STMT_VINFO_RELATED_STMT (use_stmt_info) == stmt))
{
single_defuse_cycle = true;
epilog_copies = 1;