re PR tree-optimization/86179 (ice in get_later_stmt, at tree-vectorizer.h:1108)
authorRichard Biener <rguenther@suse.de>
Tue, 19 Jun 2018 06:53:04 +0000 (06:53 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 19 Jun 2018 06:53:04 +0000 (06:53 +0000)
2018-06-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86179
* tree-vect-patterns.c (vect_pattern_recog_1): Clean up
after failed recognition.

* gcc.dg/pr86179.c: New testcase.

From-SVN: r261731

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr86179.c [new file with mode: 0644]
gcc/tree-vect-patterns.c

index 239d08aa6a181773a74b7ee0e7af782999a5f955..e1b5d2a00b97958406b3771b447fbe65721d386a 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86179
+       * tree-vect-patterns.c (vect_pattern_recog_1): Clean up
+       after failed recognition.
+
 2018-06-18  Martin Sebor  <msebor@redhat.com>
 
        PR middle-end/85602
index b3b13226d2779b442e44c741b99614046952890c..67835408169b53a7699d510a47f3ce9bae7bc6c7 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86179
+       * gcc.dg/pr86179.c: New testcase.
+
 2018-06-18  Martin Sebor  <msebor@redhat.com>
 
        PR middle-end/85602
diff --git a/gcc/testsuite/gcc.dg/pr86179.c b/gcc/testsuite/gcc.dg/pr86179.c
new file mode 100644 (file)
index 0000000..6a90f09
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+void c(int *d, char *g)
+{
+  char *a, *b, *e;
+  int f;
+  for (; f; f -= 8) {
+      *d++ = *e++ | (unsigned)*g++ << 8 | (unsigned)*b++ << 16 |
+         (unsigned)*a++ << 24;
+      *d++ = *e++ | (unsigned)*g++ << 8 | (unsigned)*b++ << 16 |
+         (unsigned)*a++ << 24;
+  }
+}
index c530810aa3e5a92c19453c494a2db8d1c15aeefd..19d4ea9fb323eb2c6a5302666432cb9c71399172 100644 (file)
@@ -4496,7 +4496,18 @@ vect_pattern_recog_1 (vect_recog_func *recog_func,
   stmts_to_replace->quick_push (stmt);
   pattern_stmt = recog_func->fn (stmts_to_replace, &type_in, &type_out);
   if (!pattern_stmt)
-    return false;
+    {
+      /* Clear related stmt info that analysis might have noted for
+         to be replaced stmts.  */
+      for (i = 0; stmts_to_replace->iterate (i, &stmt)
+          && (unsigned) i < stmts_to_replace->length ();
+          i++)
+       {
+         stmt_info = vinfo_for_stmt (stmt);
+         STMT_VINFO_RELATED_STMT (stmt_info) = NULL;
+       }
+      return false;
+    }
 
   stmt = stmts_to_replace->last ();
   stmt_info = vinfo_for_stmt (stmt);
@@ -4668,7 +4679,6 @@ vect_pattern_recog (vec_info *vinfo)
   gimple_stmt_iterator si;
   unsigned int i, j;
   auto_vec<gimple *, 1> stmts_to_replace;
-  gimple *stmt;
 
   DUMP_VECT_SCOPE ("vect_pattern_recog");
 
@@ -4685,6 +4695,10 @@ vect_pattern_recog (vec_info *vinfo)
          basic_block bb = bbs[i];
          for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
            {
+             gimple *stmt = gsi_stmt (si);
+             stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+             if (stmt_info && STMT_VINFO_IN_PATTERN_P (stmt_info))
+               continue;
              /* Scan over all generic vect_recog_xxx_pattern functions.  */
              for (j = 0; j < NUM_PATTERNS; j++)
                if (vect_pattern_recog_1 (&vect_vect_recog_func_ptrs[j], si,
@@ -4699,9 +4713,11 @@ vect_pattern_recog (vec_info *vinfo)
       for (si = bb_vinfo->region_begin;
           gsi_stmt (si) != gsi_stmt (bb_vinfo->region_end); gsi_next (&si))
        {
-         if ((stmt = gsi_stmt (si))
-             && vinfo_for_stmt (stmt)
-             && !STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (stmt)))
+         gimple *stmt = gsi_stmt (si);
+         stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+         if (stmt_info
+             && (!STMT_VINFO_VECTORIZABLE (stmt_info)
+                 || STMT_VINFO_IN_PATTERN_P (stmt_info)))
            continue;
 
          /* Scan over all generic vect_recog_xxx_pattern functions.  */