diff mbox series

[2/6] Make vec_info::lookup_single_use take a stmt_vec_info

Message ID 87lg8qrb2z.fsf@arm.com
State New
Headers show
Series Make vector pattern statements less special | expand

Commit Message

Richard Sandiford Aug. 28, 2018, 11:21 a.m. UTC
All callers to vec_info::lookup_single_use are asking about the lhs of a
statement that they're already examining.  It makes more sense to pass
that statement instead of the SSA name, since it is then easier to
handle statements that have been replaced by pattern statements.

A later patch adds support for pattern statements.  This one just
changes the interface to make that possible.


2018-08-28  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vectorizer.h (vec_info::lookup_single_use): Take a
	stmt_vec_info instead of an SSA name.
	* tree-vectorizer.c (vec_info::lookup_single_use): Likewise.
	* tree-vect-loop.c (vectorizable_reduction): Update call
	accordingly.
	* tree-vect-stmts.c (supportable_widening_operation): Likewise.

Comments

Jeff Law Aug. 28, 2018, 6:25 p.m. UTC | #1
On 08/28/2018 05:21 AM, Richard Sandiford wrote:
> All callers to vec_info::lookup_single_use are asking about the lhs of a
> statement that they're already examining.  It makes more sense to pass
> that statement instead of the SSA name, since it is then easier to
> handle statements that have been replaced by pattern statements.
> 
> A later patch adds support for pattern statements.  This one just
> changes the interface to make that possible.
> 
> 
> 2018-08-28  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/
> 	* tree-vectorizer.h (vec_info::lookup_single_use): Take a
> 	stmt_vec_info instead of an SSA name.
> 	* tree-vectorizer.c (vec_info::lookup_single_use): Likewise.
> 	* tree-vect-loop.c (vectorizable_reduction): Update call
> 	accordingly.
> 	* tree-vect-stmts.c (supportable_widening_operation): Likewise.
OK
jeff
diff mbox series

Patch

Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h	2018-08-01 16:14:45.107097179 +0100
+++ gcc/tree-vectorizer.h	2018-08-28 12:05:08.743005901 +0100
@@ -220,7 +220,7 @@  struct vec_info {
   stmt_vec_info add_stmt (gimple *);
   stmt_vec_info lookup_stmt (gimple *);
   stmt_vec_info lookup_def (tree);
-  stmt_vec_info lookup_single_use (tree);
+  stmt_vec_info lookup_single_use (stmt_vec_info);
   struct dr_vec_info *lookup_dr (data_reference *);
   void move_dr (stmt_vec_info, stmt_vec_info);
   void remove_stmt (stmt_vec_info);
Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	2018-08-21 14:47:07.795167843 +0100
+++ gcc/tree-vectorizer.c	2018-08-28 12:05:08.743005901 +0100
@@ -544,13 +544,14 @@  vec_info::lookup_def (tree name)
   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.  */
+/* See whether there is a single non-debug use of the lhs of STMT_INFO
+   and whether the containing 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)
+vec_info::lookup_single_use (stmt_vec_info stmt_info)
 {
+  tree lhs = gimple_get_lhs (stmt_info->stmt);
   use_operand_p dummy;
   gimple *use_stmt;
   if (single_imm_use (lhs, &dummy, &use_stmt))
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	2018-08-28 12:05:06.207027289 +0100
+++ gcc/tree-vect-loop.c	2018-08-28 12:05:08.743005901 +0100
@@ -6180,7 +6180,7 @@  vectorizable_reduction (stmt_vec_info st
       stmt_vec_info use_stmt_info;
       if (ncopies > 1
 	  && STMT_VINFO_RELEVANT (reduc_stmt_info) <= vect_used_only_live
-	  && (use_stmt_info = loop_vinfo->lookup_single_use (phi_result))
+	  && (use_stmt_info = loop_vinfo->lookup_single_use (stmt_info))
 	  && vect_stmt_to_vectorize (use_stmt_info) == reduc_stmt_info)
 	single_defuse_cycle = true;
 
@@ -6947,10 +6947,9 @@  vectorizable_reduction (stmt_vec_info st
    in vectorizable_reduction and there are no intermediate stmts
    participating.  */
   stmt_vec_info use_stmt_info;
-  tree reduc_phi_result = gimple_phi_result (reduc_def_phi);
   if (ncopies > 1
       && (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live)
-      && (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result))
+      && (use_stmt_info = loop_vinfo->lookup_single_use (reduc_def_info))
       && vect_stmt_to_vectorize (use_stmt_info) == stmt_info)
     {
       single_defuse_cycle = true;
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	2018-08-28 12:05:06.211027256 +0100
+++ gcc/tree-vect-stmts.c	2018-08-28 12:05:08.743005901 +0100
@@ -10237,8 +10237,8 @@  supportable_widening_operation (enum tre
              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
              by STMT is only directly used in the reduction statement.  */
-	  tree lhs = gimple_assign_lhs (stmt_info->stmt);
-	  stmt_vec_info use_stmt_info = loop_info->lookup_single_use (lhs);
+	  stmt_vec_info use_stmt_info
+	    = loop_info->lookup_single_use (stmt_info);
 	  if (use_stmt_info
 	      && STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def)
 	    return true;