Re: [PATCH] Remove unused DR_GROUP_SAME_DR_STMT

2019-04-10 Thread Richard Biener
yOn Tue, 9 Apr 2019, Richard Biener wrote:

> 
> While looking at PR90018 I figured DR_GROUP_SAME_DR_STMT is never
> set since GCC 4.9.  The following removes it to confuse the
> occasional reader of the vectorizer code less.
> 
> Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.

Testing shows an issue in the new group splitting being done
(comparing 8(OVF) with 8 by pointer equality) and a write-only
variable leftover.

I've applied the following instead.

Bootstrapped/tested on x86_64-unknown-linux-gnu.

Richard.

2019-04-10  Richard Biener  

* tree-vectorizer.h (_stmt_vec_info): Remove same_dr_stmt
member.
(DR_GROUP_SAME_DR_STMT): Remove.
* tree-vect-stmts.c (vectorizable_load): Remove unreachable code.
* tree-vect-data-refs.c (vect_analyze_group_access_1): Likewise,
replace with assert.
(vect_analyze_data_ref_accesses): Fix INTEGER_CST comparison.
(vect_record_grouped_load_vectors): Remove unreachable code.

Index: gcc/tree-vectorizer.h
===
--- gcc/tree-vectorizer.h   (revision 270223)
+++ gcc/tree-vectorizer.h   (working copy)
@@ -872,9 +872,6 @@ struct _stmt_vec_info {
   stmt_vec_info first_element;
   /* Pointer to the next element in the group.  */
   stmt_vec_info next_element;
-  /* For data-refs, in case that two or more stmts share data-ref, this is the
- pointer to the previously detected stmt with the same dr.  */
-  stmt_vec_info same_dr_stmt;
   /* The size of the group.  */
   unsigned int size;
   /* For stores, number of stores from this group seen. We vectorize the last
@@ -1044,8 +1041,6 @@ STMT_VINFO_BB_VINFO (stmt_vec_info stmt_
   (gcc_checking_assert ((S)->dr_aux.dr), (S)->store_count)
 #define DR_GROUP_GAP(S) \
   (gcc_checking_assert ((S)->dr_aux.dr), (S)->gap)
-#define DR_GROUP_SAME_DR_STMT(S) \
-  (gcc_checking_assert ((S)->dr_aux.dr), (S)->same_dr_stmt)
 
 #define REDUC_GROUP_FIRST_ELEMENT(S) \
   (gcc_checking_assert (!(S)->dr_aux.dr), (S)->first_element)
Index: gcc/tree-vect-stmts.c
===
--- gcc/tree-vect-stmts.c   (revision 270223)
+++ gcc/tree-vect-stmts.c   (working copy)
@@ -7704,19 +7727,6 @@ vectorizable_load (stmt_vec_info stmt_in
 "group loads with negative dependence distance\n");
  return false;
}
-
-  /* Similarly when the stmt is a load that is both part of a SLP
- instance and a loop vectorized stmt via the same-dr mechanism
-we have to give up.  */
-  if (DR_GROUP_SAME_DR_STMT (stmt_info)
- && (STMT_SLP_TYPE (stmt_info)
- != STMT_SLP_TYPE (DR_GROUP_SAME_DR_STMT (stmt_info
-   {
- if (dump_enabled_p ())
-   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-"conflicting SLP types for CSEd load\n");
- return false;
-   }
 }
   else
 group_size = 1;
Index: gcc/tree-vect-data-refs.c
===
--- gcc/tree-vect-data-refs.c   (revision 270245)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -2523,40 +2562,15 @@ vect_analyze_group_access_1 (dr_vec_info
   struct data_reference *data_ref = dr;
   unsigned int count = 1;
   tree prev_init = DR_INIT (data_ref);
-  stmt_vec_info prev = stmt_info;
   HOST_WIDE_INT diff, gaps = 0;
 
   /* By construction, all group members have INTEGER_CST DR_INITs.  */
   while (next)
 {
-  /* Skip same data-refs.  In case that two or more stmts share
- data-ref (supported only for loads), we vectorize only the first
- stmt, and the rest get their vectorized loads from the first
- one.  */
-  if (!tree_int_cst_compare (DR_INIT (data_ref),
-DR_INIT (STMT_VINFO_DATA_REF (next
-{
-  if (DR_IS_WRITE (data_ref))
-{
-  if (dump_enabled_p ())
-dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "Two store stmts share the same dr.\n");
-  return false;
-}
-
- if (dump_enabled_p ())
-   dump_printf_loc (MSG_NOTE, vect_location,
-"Two or more load stmts share the same dr.\n");
+  /* We never have the same DR multiple times.  */
+  gcc_assert (tree_int_cst_compare (DR_INIT (data_ref),
+   DR_INIT (STMT_VINFO_DATA_REF (next))) != 0);
 
- /* For load use the same data-ref load.  */
- DR_GROUP_SAME_DR_STMT (next) = prev;
-
- prev = next;
- next = DR_GROUP_NEXT_ELEMENT (next);
- continue;
-}
-
- prev = next;
  data_ref = STMT_VINFO_DATA_REF (next);
 
  

[PATCH] Remove unused DR_GROUP_SAME_DR_STMT

2019-04-09 Thread Richard Biener


While looking at PR90018 I figured DR_GROUP_SAME_DR_STMT is never
set since GCC 4.9.  The following removes it to confuse the
occasional reader of the vectorizer code less.

Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.

Richard.

2019-04-09  Richard Biener  

* tree-vectorizer.h (_stmt_vec_info): Remove same_dr_stmt
member.
(DR_GROUP_SAME_DR_STMT): Remove.
* tree-vect-stmts.c (vectorizable_load): Remove unreachable code.
* tree-vect-data-refs.c (vect_analyze_group_access_1): Likewise,
replace with assert.
(vect_record_grouped_load_vectors): Remove unreachable code.

Index: gcc/tree-vectorizer.h
===
--- gcc/tree-vectorizer.h   (revision 270223)
+++ gcc/tree-vectorizer.h   (working copy)
@@ -872,9 +872,6 @@ struct _stmt_vec_info {
   stmt_vec_info first_element;
   /* Pointer to the next element in the group.  */
   stmt_vec_info next_element;
-  /* For data-refs, in case that two or more stmts share data-ref, this is the
- pointer to the previously detected stmt with the same dr.  */
-  stmt_vec_info same_dr_stmt;
   /* The size of the group.  */
   unsigned int size;
   /* For stores, number of stores from this group seen. We vectorize the last
@@ -1044,8 +1041,6 @@ STMT_VINFO_BB_VINFO (stmt_vec_info stmt_
   (gcc_checking_assert ((S)->dr_aux.dr), (S)->store_count)
 #define DR_GROUP_GAP(S) \
   (gcc_checking_assert ((S)->dr_aux.dr), (S)->gap)
-#define DR_GROUP_SAME_DR_STMT(S) \
-  (gcc_checking_assert ((S)->dr_aux.dr), (S)->same_dr_stmt)
 
 #define REDUC_GROUP_FIRST_ELEMENT(S) \
   (gcc_checking_assert (!(S)->dr_aux.dr), (S)->first_element)
Index: gcc/tree-vect-stmts.c
===
--- gcc/tree-vect-stmts.c   (revision 270223)
+++ gcc/tree-vect-stmts.c   (working copy)
@@ -7704,19 +7727,6 @@ vectorizable_load (stmt_vec_info stmt_in
 "group loads with negative dependence distance\n");
  return false;
}
-
-  /* Similarly when the stmt is a load that is both part of a SLP
- instance and a loop vectorized stmt via the same-dr mechanism
-we have to give up.  */
-  if (DR_GROUP_SAME_DR_STMT (stmt_info)
- && (STMT_SLP_TYPE (stmt_info)
- != STMT_SLP_TYPE (DR_GROUP_SAME_DR_STMT (stmt_info
-   {
- if (dump_enabled_p ())
-   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-"conflicting SLP types for CSEd load\n");
- return false;
-   }
 }
   else
 group_size = 1;
Index: gcc/tree-vect-data-refs.c
===
--- gcc/tree-vect-data-refs.c   (revision 270223)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -2529,32 +2529,9 @@ vect_analyze_group_access_1 (dr_vec_info
   /* By construction, all group members have INTEGER_CST DR_INITs.  */
   while (next)
 {
-  /* Skip same data-refs.  In case that two or more stmts share
- data-ref (supported only for loads), we vectorize only the first
- stmt, and the rest get their vectorized loads from the first
- one.  */
-  if (!tree_int_cst_compare (DR_INIT (data_ref),
-DR_INIT (STMT_VINFO_DATA_REF (next
-{
-  if (DR_IS_WRITE (data_ref))
-{
-  if (dump_enabled_p ())
-dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "Two store stmts share the same dr.\n");
-  return false;
-}
-
- if (dump_enabled_p ())
-   dump_printf_loc (MSG_NOTE, vect_location,
-"Two or more load stmts share the same dr.\n");
-
- /* For load use the same data-ref load.  */
- DR_GROUP_SAME_DR_STMT (next) = prev;
-
- prev = next;
- next = DR_GROUP_NEXT_ELEMENT (next);
- continue;
-}
+  /* We never have the same DR multiple times.  */
+  gcc_assert (tree_int_cst_compare (DR_INIT (data_ref),
+   DR_INIT (STMT_VINFO_DATA_REF (next))) != 0);
 
  prev = next;
  data_ref = STMT_VINFO_DATA_REF (next);
@@ -6329,12 +6306,14 @@ vect_record_grouped_load_vectors (stmt_v
correspond to the gaps.  */
   if (next_stmt_info != first_stmt_info
  && gap_count < DR_GROUP_GAP (next_stmt_info))
-  {
-gap_count++;
-continue;
-  }
+   {
+ gap_count++;
+ continue;
+   }
 
-  while (next_stmt_info)
+  /* ???  The following needs cleanup after the removal of
+ DR_GROUP_SAME_DR_STMT.  */
+  if (next_stmt_info)
 {
  stmt_vec_info new_stmt_info = vinfo->lookup_def