public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [25/46] Make get_earlier/later_stmt take and return stmt_vec_infos
Date: Tue, 24 Jul 2018 10:03:00 -0000	[thread overview]
Message-ID: <87wotlne7f.fsf@arm.com> (raw)
In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24	Jul 2018 10:52:16 +0100")

...and also make vect_find_last_scalar_stmt_in_slp return a stmt_vec_info.


2018-07-24  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vectorizer.h (get_earlier_stmt, get_later_stmt): Take and
	return stmt_vec_infos rather than gimple stmts.  Do not accept
	null arguments.
	(vect_find_last_scalar_stmt_in_slp): Return a stmt_vec_info instead
	of a gimple stmt.
	* tree-vect-slp.c (vect_find_last_scalar_stmt_in_slp): Likewise.
	Update use of get_later_stmt.
	(vect_get_constant_vectors): Update call accordingly.
	(vect_schedule_slp_instance): Likewise
	* tree-vect-data-refs.c (vect_slp_analyze_node_dependences): Likewise.
	(vect_slp_analyze_instance_dependence): Likewise.
	(vect_preserves_scalar_order_p): Update use of get_earlier_stmt.

Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h	2018-07-24 10:23:22.264848493 +0100
+++ gcc/tree-vectorizer.h	2018-07-24 10:23:25.232822136 +0100
@@ -1119,68 +1119,36 @@ set_vinfo_for_stmt (gimple *stmt, stmt_v
     }
 }
 
-/* Return the earlier statement between STMT1 and STMT2.  */
+/* Return the earlier statement between STMT1_INFO and STMT2_INFO.  */
 
-static inline gimple *
-get_earlier_stmt (gimple *stmt1, gimple *stmt2)
+static inline stmt_vec_info
+get_earlier_stmt (stmt_vec_info stmt1_info, stmt_vec_info stmt2_info)
 {
-  unsigned int uid1, uid2;
+  gcc_checking_assert ((STMT_VINFO_IN_PATTERN_P (stmt1_info)
+			|| !STMT_VINFO_RELATED_STMT (stmt1_info))
+		       && (STMT_VINFO_IN_PATTERN_P (stmt2_info)
+			   || !STMT_VINFO_RELATED_STMT (stmt2_info)));
 
-  if (stmt1 == NULL)
-    return stmt2;
-
-  if (stmt2 == NULL)
-    return stmt1;
-
-  uid1 = gimple_uid (stmt1);
-  uid2 = gimple_uid (stmt2);
-
-  if (uid1 == 0 || uid2 == 0)
-    return NULL;
-
-  gcc_assert (uid1 <= stmt_vec_info_vec->length ()
-	      && uid2 <= stmt_vec_info_vec->length ());
-  gcc_checking_assert ((STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (stmt1))
-			|| !STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt1)))
-		       && (STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (stmt2))
-			   || !STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt2))));
-
-  if (uid1 < uid2)
-    return stmt1;
+  if (gimple_uid (stmt1_info->stmt) < gimple_uid (stmt2_info->stmt))
+    return stmt1_info;
   else
-    return stmt2;
+    return stmt2_info;
 }
 
-/* Return the later statement between STMT1 and STMT2.  */
+/* Return the later statement between STMT1_INFO and STMT2_INFO.  */
 
-static inline gimple *
-get_later_stmt (gimple *stmt1, gimple *stmt2)
+static inline stmt_vec_info
+get_later_stmt (stmt_vec_info stmt1_info, stmt_vec_info stmt2_info)
 {
-  unsigned int uid1, uid2;
-
-  if (stmt1 == NULL)
-    return stmt2;
-
-  if (stmt2 == NULL)
-    return stmt1;
-
-  uid1 = gimple_uid (stmt1);
-  uid2 = gimple_uid (stmt2);
-
-  if (uid1 == 0 || uid2 == 0)
-    return NULL;
-
-  gcc_assert (uid1 <= stmt_vec_info_vec->length ()
-	      && uid2 <= stmt_vec_info_vec->length ());
-  gcc_checking_assert ((STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (stmt1))
-			|| !STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt1)))
-		       && (STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (stmt2))
-			   || !STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt2))));
+  gcc_checking_assert ((STMT_VINFO_IN_PATTERN_P (stmt1_info)
+			|| !STMT_VINFO_RELATED_STMT (stmt1_info))
+		       && (STMT_VINFO_IN_PATTERN_P (stmt2_info)
+			   || !STMT_VINFO_RELATED_STMT (stmt2_info)));
 
-  if (uid1 > uid2)
-    return stmt1;
+  if (gimple_uid (stmt1_info->stmt) > gimple_uid (stmt2_info->stmt))
+    return stmt1_info;
   else
-    return stmt2;
+    return stmt2_info;
 }
 
 /* Return TRUE if a statement represented by STMT_INFO is a part of a
@@ -1674,7 +1642,7 @@ extern bool vect_make_slp_decision (loop
 extern void vect_detect_hybrid_slp (loop_vec_info);
 extern void vect_get_slp_defs (vec<tree> , slp_tree, vec<vec<tree> > *);
 extern bool vect_slp_bb (basic_block);
-extern gimple *vect_find_last_scalar_stmt_in_slp (slp_tree);
+extern stmt_vec_info vect_find_last_scalar_stmt_in_slp (slp_tree);
 extern bool is_simple_and_all_uses_invariant (gimple *, loop_vec_info);
 extern bool can_duplicate_and_interleave_p (unsigned int, machine_mode,
 					    unsigned int * = NULL,
Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	2018-07-24 10:23:12.060939107 +0100
+++ gcc/tree-vect-slp.c	2018-07-24 10:23:25.232822136 +0100
@@ -1838,18 +1838,17 @@ vect_supported_load_permutation_p (slp_i
 
 /* Find the last store in SLP INSTANCE.  */
 
-gimple *
+stmt_vec_info
 vect_find_last_scalar_stmt_in_slp (slp_tree node)
 {
-  gimple *last = NULL;
+  stmt_vec_info last = NULL;
   stmt_vec_info stmt_vinfo;
 
   for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++)
     {
       if (is_pattern_stmt_p (stmt_vinfo))
-	last = get_later_stmt (STMT_VINFO_RELATED_STMT (stmt_vinfo), last);
-      else
-	last = get_later_stmt (stmt_vinfo, last);
+	stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo);
+      last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo;
     }
 
   return last;
@@ -3480,8 +3479,9 @@ vect_get_constant_vectors (tree op, slp_
 	      gimple_stmt_iterator gsi;
 	      if (place_after_defs)
 		{
-		  gsi = gsi_for_stmt
-		          (vect_find_last_scalar_stmt_in_slp (slp_node));
+		  stmt_vec_info last_stmt_info
+		    = vect_find_last_scalar_stmt_in_slp (slp_node);
+		  gsi = gsi_for_stmt (last_stmt_info->stmt);
 		  init = vect_init_vector (stmt_vinfo, vec_cst, vector_type,
 					   &gsi);
 		}
@@ -3910,7 +3910,8 @@ vect_schedule_slp_instance (slp_tree nod
 
   /* Vectorized stmts go before the last scalar stmt which is where
      all uses are ready.  */
-  si = gsi_for_stmt (vect_find_last_scalar_stmt_in_slp (node));
+  stmt_vec_info last_stmt_info = vect_find_last_scalar_stmt_in_slp (node);
+  si = gsi_for_stmt (last_stmt_info->stmt);
 
   /* Mark the first element of the reduction chain as reduction to properly
      transform the node.  In the analysis phase only the last element of the
Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	2018-07-24 10:23:18.856878757 +0100
+++ gcc/tree-vect-data-refs.c	2018-07-24 10:23:25.228822172 +0100
@@ -216,8 +216,8 @@ vect_preserves_scalar_order_p (gimple *s
     stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a);
   if (is_pattern_stmt_p (stmtinfo_b))
     stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b);
-  gimple *earlier_stmt = get_earlier_stmt (stmtinfo_a, stmtinfo_b);
-  return !DR_IS_WRITE (STMT_VINFO_DATA_REF (vinfo_for_stmt (earlier_stmt)));
+  stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, stmtinfo_b);
+  return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info));
 }
 
 /* A subroutine of vect_analyze_data_ref_dependence.  Handle
@@ -671,17 +671,17 @@ vect_slp_analyze_node_dependences (slp_i
   /* This walks over all stmts involved in the SLP load/store done
      in NODE verifying we can sink them up to the last stmt in the
      group.  */
-  gimple *last_access = vect_find_last_scalar_stmt_in_slp (node);
+  stmt_vec_info last_access_info = vect_find_last_scalar_stmt_in_slp (node);
   for (unsigned k = 0; k < SLP_INSTANCE_GROUP_SIZE (instance); ++k)
     {
       stmt_vec_info access_info = SLP_TREE_SCALAR_STMTS (node)[k];
-      if (access_info == last_access)
+      if (access_info == last_access_info)
 	continue;
       data_reference *dr_a = STMT_VINFO_DATA_REF (access_info);
       ao_ref ref;
       bool ref_initialized_p = false;
       for (gimple_stmt_iterator gsi = gsi_for_stmt (access_info->stmt);
-	   gsi_stmt (gsi) != last_access; gsi_next (&gsi))
+	   gsi_stmt (gsi) != last_access_info->stmt; gsi_next (&gsi))
 	{
 	  gimple *stmt = gsi_stmt (gsi);
 	  if (! gimple_vuse (stmt)
@@ -757,14 +757,14 @@ vect_slp_analyze_instance_dependence (sl
     store = NULL;
 
   /* Verify we can sink stores to the vectorized stmt insert location.  */
-  gimple *last_store = NULL;
+  stmt_vec_info last_store_info = NULL;
   if (store)
     {
       if (! vect_slp_analyze_node_dependences (instance, store, vNULL, NULL))
 	return false;
 
       /* Mark stores in this instance and remember the last one.  */
-      last_store = vect_find_last_scalar_stmt_in_slp (store);
+      last_store_info = vect_find_last_scalar_stmt_in_slp (store);
       for (unsigned k = 0; k < SLP_INSTANCE_GROUP_SIZE (instance); ++k)
 	gimple_set_visited (SLP_TREE_SCALAR_STMTS (store)[k]->stmt, true);
     }
@@ -779,7 +779,7 @@ vect_slp_analyze_instance_dependence (sl
     if (! vect_slp_analyze_node_dependences (instance, load,
 					     store
 					     ? SLP_TREE_SCALAR_STMTS (store)
-					     : vNULL, last_store))
+					     : vNULL, last_store_info))
       {
 	res = false;
 	break;

  parent reply	other threads:[~2018-07-24 10:03 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24  9:52 [00/46] Remove vinfo_for_stmt etc Richard Sandiford
2018-07-24  9:52 ` [01/46] Move special cases out of get_initial_def_for_reduction Richard Sandiford
2018-07-25  8:42   ` Richard Biener
2018-07-24  9:53 ` [03/46] Remove unnecessary update of NUM_SLP_USES Richard Sandiford
2018-07-25  8:46   ` Richard Biener
2018-07-24  9:53 ` [02/46] Remove dead vectorizable_reduction code Richard Sandiford
2018-07-25  8:43   ` Richard Biener
2018-07-24  9:54 ` [05/46] Fix make_ssa_name call in vectorizable_reduction Richard Sandiford
2018-07-25  8:47   ` Richard Biener
2018-07-24  9:54 ` [04/46] Factor out the test for a valid reduction input Richard Sandiford
2018-07-25  8:46   ` Richard Biener
2018-07-24  9:55 ` [08/46] Add vec_info::lookup_def Richard Sandiford
2018-07-25  9:12   ` Richard Biener
2018-07-24  9:55 ` [06/46] Add vec_info::add_stmt Richard Sandiford
2018-07-25  9:10   ` Richard Biener
2018-07-24  9:55 ` [07/46] Add vec_info::lookup_stmt Richard Sandiford
2018-07-25  9:11   ` Richard Biener
2018-07-24  9:56 ` [09/46] Add vec_info::lookup_single_use Richard Sandiford
2018-07-25  9:13   ` Richard Biener
2018-07-24  9:57 ` [11/46] Pass back a stmt_vec_info from vect_is_simple_use Richard Sandiford
2018-07-25  9:18   ` Richard Biener
2018-07-24  9:57 ` [10/46] Temporarily make stmt_vec_info a class Richard Sandiford
2018-07-25  9:14   ` Richard Biener
2018-07-24  9:58 ` [12/46] Make vect_finish_stmt_generation return a stmt_vec_info Richard Sandiford
2018-07-25  9:19   ` Richard Biener
2018-07-24  9:58 ` [13/46] Make STMT_VINFO_RELATED_STMT " Richard Sandiford
2018-07-25  9:19   ` Richard Biener
2018-07-24  9:58 ` [14/46] Make STMT_VINFO_VEC_STMT " Richard Sandiford
2018-07-25  9:21   ` Richard Biener
2018-07-25 11:03     ` Richard Sandiford
2018-08-02  0:22   ` H.J. Lu
2018-08-02  9:58     ` Richard Sandiford
2018-07-24  9:59 ` [16/46] Make STMT_VINFO_REDUC_DEF " Richard Sandiford
2018-07-25  9:22   ` Richard Biener
2018-07-24  9:59 ` [17/46] Make LOOP_VINFO_REDUCTIONS an auto_vec<stmt_vec_info> Richard Sandiford
2018-07-25  9:23   ` Richard Biener
2018-07-24  9:59 ` [15/46] Make SLP_TREE_VEC_STMTS a vec<stmt_vec_info> Richard Sandiford
2018-07-25  9:22   ` Richard Biener
2018-07-24 10:00 ` [18/46] Make SLP_TREE_SCALAR_STMTS " Richard Sandiford
2018-07-25  9:27   ` Richard Biener
2018-07-31 15:03     ` Richard Sandiford
2018-07-24 10:01 ` [19/46] Make vect_dr_stmt return a stmt_vec_info Richard Sandiford
2018-07-25  9:28   ` Richard Biener
2018-07-24 10:01 ` [20/46] Make *FIRST_ELEMENT and *NEXT_ELEMENT stmt_vec_infos Richard Sandiford
2018-07-25  9:28   ` Richard Biener
2018-07-24 10:01 ` [21/46] Make grouped_stores and reduction_chains use stmt_vec_infos Richard Sandiford
2018-07-25  9:28   ` Richard Biener
2018-07-24 10:02 ` [22/46] Make DR_GROUP_SAME_DR_STMT a stmt_vec_info Richard Sandiford
2018-07-25  9:29   ` Richard Biener
2018-07-24 10:02 ` [24/46] Make stmt_info_for_cost use " Richard Sandiford
2018-07-25  9:30   ` Richard Biener
2018-07-24 10:02 ` [23/46] Make LOOP_VINFO_MAY_MISALIGN_STMTS use stmt_vec_info Richard Sandiford
2018-07-25  9:29   ` Richard Biener
2018-07-24 10:03 ` Richard Sandiford [this message]
2018-07-25  9:31   ` [25/46] Make get_earlier/later_stmt take and return stmt_vec_infos Richard Biener
2018-07-24 10:03 ` [26/46] Make more use of dyn_cast in tree-vect* Richard Sandiford
2018-07-25  9:31   ` Richard Biener
2018-07-24 10:03 ` [27/46] Remove duplicated stmt_vec_info lookups Richard Sandiford
2018-07-25  9:32   ` Richard Biener
2018-07-24 10:04 ` [29/46] Use stmt_vec_info instead of gimple stmts internally (part 2) Richard Sandiford
2018-07-25 10:03   ` Richard Biener
2018-07-24 10:04 ` [28/46] Use stmt_vec_info instead of gimple stmts internally (part 1) Richard Sandiford
2018-07-25  9:33   ` Richard Biener
2018-07-24 10:04 ` [30/46] Use stmt_vec_infos rather than gimple stmts for worklists Richard Sandiford
2018-07-25 10:04   ` Richard Biener
2018-07-24 10:05 ` [32/46] Use stmt_vec_info in function interfaces (part 2) Richard Sandiford
2018-07-25 10:06   ` Richard Biener
2018-07-24 10:05 ` [31/46] Use stmt_vec_info in function interfaces (part 1) Richard Sandiford
2018-07-25 10:05   ` Richard Biener
2018-07-24 10:06 ` [34/46] Alter interface to vect_get_vec_def_for_stmt_copy Richard Sandiford
2018-07-25 10:13   ` Richard Biener
2018-07-24 10:06 ` [33/46] Use stmt_vec_infos instead of vec_info/gimple stmt pairs Richard Sandiford
2018-07-25 10:06   ` Richard Biener
2018-07-24 10:06 ` [35/46] Alter interfaces within vect_pattern_recog Richard Sandiford
2018-07-25 10:14   ` Richard Biener
2018-07-24 10:07 ` [36/46] Add a pattern_stmt_p field to stmt_vec_info Richard Sandiford
2018-07-25 10:15   ` Richard Biener
2018-07-25 11:09     ` Richard Sandiford
2018-07-25 11:48       ` Richard Biener
2018-07-26 10:29         ` Richard Sandiford
2018-07-26 11:15           ` Richard Biener
2018-07-24 10:07 ` [37/46] Associate alignment information with stmt_vec_infos Richard Sandiford
2018-07-25 10:18   ` Richard Biener
2018-07-26 10:55     ` Richard Sandiford
2018-07-26 11:13       ` Richard Biener
2018-07-24 10:08 ` [39/46] Replace STMT_VINFO_UNALIGNED_DR with the associated statement Richard Sandiford
2018-07-26 11:08   ` [39/46 v2] Change STMT_VINFO_UNALIGNED_DR to a dr_vec_info Richard Sandiford
2018-07-26 11:13     ` Richard Biener
2018-07-24 10:08 ` [38/46] Pass stmt_vec_infos instead of data_references where relevant Richard Sandiford
2018-07-25 10:21   ` Richard Biener
2018-07-25 11:21     ` Richard Sandiford
2018-07-26 11:05       ` Richard Sandiford
2018-07-26 11:13         ` Richard Biener
2018-07-24 10:09 ` [40/46] Add vec_info::lookup_dr Richard Sandiford
2018-07-26 11:10   ` [40/46 v2] " Richard Sandiford
2018-07-26 11:16     ` Richard Biener
2018-07-24 10:09 ` [42/46] Add vec_info::replace_stmt Richard Sandiford
2018-07-31 12:03   ` Richard Biener
2018-07-24 10:09 ` [41/46] Add vec_info::remove_stmt Richard Sandiford
2018-07-31 12:02   ` Richard Biener
2018-07-24 10:10 ` [43/46] Make free_stmt_vec_info take a stmt_vec_info Richard Sandiford
2018-07-31 12:03   ` Richard Biener
2018-07-24 10:10 ` [45/46] Remove vect_stmt_in_region_p Richard Sandiford
2018-07-31 12:06   ` Richard Biener
2018-07-24 10:10 ` [44/46] Remove global vinfo_for_stmt-related routines Richard Sandiford
2018-07-31 12:05   ` Richard Biener
2018-07-24 10:11 ` [46/46] Turn stmt_vec_info back into a typedef Richard Sandiford
2018-07-31 12:07   ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wotlne7f.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).