tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make sure to use non-pattern...
authorRichard Biener <rguenther@suse.de>
Tue, 29 May 2018 14:35:28 +0000 (14:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 29 May 2018 14:35:28 +0000 (14:35 +0000)
2018-05-29  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make
sure to use non-pattern stmts for get_earlier_stmt arguments.
* tree-vectorizer.h (get_earlier_stmt): Assert we do not get
called on pattern stmts.
(get_later_stmt): Likewise.

From-SVN: r260896

gcc/ChangeLog
gcc/tree-vect-data-refs.c
gcc/tree-vectorizer.h

index b70c037273194451e6872f3d987fe7cd85001609..ccf3b28d275cd8d4f049ee8f3b3aee374f910b19 100644 (file)
@@ -1,3 +1,11 @@
+2018-05-29  Richard Biener  <rguenther@suse.de>
+
+       * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Make
+       sure to use non-pattern stmts for get_earlier_stmt arguments.
+       * tree-vectorizer.h (get_earlier_stmt): Assert we do not get
+       called on pattern stmts.
+       (get_later_stmt): Likewise.
+
 2018-05-29  Martin Liska  <mliska@suse.cz>
 
         PR gcov-profile/85759
index f46eb467da61653ddcbea808b96735a19bdc290d..9255c53189de62c4cd2614021cd1463a48634acc 100644 (file)
@@ -212,6 +212,10 @@ vect_preserves_scalar_order_p (gimple *stmt_a, gimple *stmt_b)
      (but could happen later) while reads will happen no later than their
      current position (but could happen earlier).  Reordering is therefore
      only possible if the first access is a write.  */
+  if (is_pattern_stmt_p (stmtinfo_a))
+    stmt_a = STMT_VINFO_RELATED_STMT (stmtinfo_a);
+  if (is_pattern_stmt_p (stmtinfo_b))
+    stmt_b = STMT_VINFO_RELATED_STMT (stmtinfo_b);
   gimple *earlier_stmt = get_earlier_stmt (stmt_a, stmt_b);
   return !DR_IS_WRITE (STMT_VINFO_DATA_REF (vinfo_for_stmt (earlier_stmt)));
 }
index f7646349b65b6590f459d8ed02e3bcddffbb2ac6..25d0aae8eaa419f7d4160c1015c6d2d143b66ab2 100644 (file)
@@ -1068,8 +1068,12 @@ get_earlier_stmt (gimple *stmt1, gimple *stmt2)
   if (uid1 == 0 || uid2 == 0)
     return NULL;
 
-  gcc_checking_assert (uid1 <= stmt_vec_info_vec->length ()
-                      && uid2 <= stmt_vec_info_vec->length ());
+  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;
@@ -1096,8 +1100,12 @@ get_later_stmt (gimple *stmt1, gimple *stmt2)
   if (uid1 == 0 || uid2 == 0)
     return NULL;
 
-  gcc_assert (uid1 <= stmt_vec_info_vec->length ());
-  gcc_assert (uid2 <= stmt_vec_info_vec->length ());
+  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;