]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/87895 (ICE in purge_dead_edges, at cfgrtl.c:3246)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:12:23 +0000 (13:12 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:12:23 +0000 (13:12 +0200)
Backported from mainline
2018-11-20  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/87895
* omp-simd-clone.c (ipa_simd_modify_function_body): When removing
or replacing GIMPLE_RETURN, set EDGE_FALLTHRU on the edge to EXIT.
(simd_clone_adjust): Don't set EDGE_FALLTHRU here. In a loop that
redirects edges to EXIT to edges to incr_bb, iterate while EXIT
has any preds and always use EDGE_PRED (, 0).

* gcc.dg/gomp/pr87895-1.c: New test.
* gcc.dg/gomp/pr87895-2.c: New test.
* gcc.dg/gomp/pr87895-3.c: New test.

From-SVN: r275070

gcc/ChangeLog
gcc/omp-simd-clone.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr87895-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr87895-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr87895-3.c [new file with mode: 0644]

index fab10b03da02c85d7b7806bad706305376ed6076..131276bcf50b69b3c448955df0ed17d1a82c0b32 100644 (file)
@@ -1,6 +1,15 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/87895
+       * omp-simd-clone.c (ipa_simd_modify_function_body): When removing
+       or replacing GIMPLE_RETURN, set EDGE_FALLTHRU on the edge to EXIT.
+       (simd_clone_adjust): Don't set EDGE_FALLTHRU here. In a loop that
+       redirects edges to EXIT to edges to incr_bb, iterate while EXIT
+       has any preds and always use EDGE_PRED (, 0).
+
        2018-10-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/87647
index 99589d44664609cb5ff59ca3e0d61c9759d92400..9af80a45eb8f618528ef6ddc75dae9397f647f02 100644 (file)
@@ -993,6 +993,8 @@ ipa_simd_modify_function_body (struct cgraph_node *node,
          if (greturn *return_stmt = dyn_cast <greturn *> (stmt))
            {
              tree retval = gimple_return_retval (return_stmt);
+             edge e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
+             e->flags |= EDGE_FALLTHRU;
              if (!retval)
                {
                  gsi_remove (&gsi, true);
@@ -1133,14 +1135,9 @@ simd_clone_adjust (struct cgraph_node *node)
       basic_block orig_exit = EDGE_PRED (EXIT_BLOCK_PTR_FOR_FN (cfun), 0)->src;
       incr_bb = create_empty_bb (orig_exit);
       add_bb_to_loop (incr_bb, body_bb->loop_father);
-      /* The succ of orig_exit was EXIT_BLOCK_PTR_FOR_FN (cfun), with an empty
-        flag.  Set it now to be a FALLTHRU_EDGE.  */
-      gcc_assert (EDGE_COUNT (orig_exit->succs) == 1);
-      EDGE_SUCC (orig_exit, 0)->flags |= EDGE_FALLTHRU;
-      for (unsigned i = 0;
-          i < EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds); ++i)
+      while (EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds))
        {
-         edge e = EDGE_PRED (EXIT_BLOCK_PTR_FOR_FN (cfun), i);
+         edge e = EDGE_PRED (EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
          redirect_edge_succ (e, incr_bb);
        }
     }
index 6d31fbb97117febfecbf5dcf7d40bd42a54776a2..30c2257164f785a5e653c2f88a6995a1775bc96d 100644 (file)
@@ -1,6 +1,13 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
+
        Backported from mainline
+       2018-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/87895
+       * gcc.dg/gomp/pr87895-1.c: New test.
+       * gcc.dg/gomp/pr87895-2.c: New test.
+       * gcc.dg/gomp/pr87895-3.c: New test.
+
        2018-11-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/60994
diff --git a/gcc/testsuite/gcc.dg/gomp/pr87895-1.c b/gcc/testsuite/gcc.dg/gomp/pr87895-1.c
new file mode 100644 (file)
index 0000000..22f5c69
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/87895 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O0" } */
+
+#pragma omp declare simd
+int
+foo (int x)
+{
+  if (x == 0)
+    return 0;
+}
+
+#pragma omp declare simd
+int
+bar (int *x, int y)
+{
+  if ((y == 0) ? (*x = 0) : *x)
+    return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr87895-2.c b/gcc/testsuite/gcc.dg/gomp/pr87895-2.c
new file mode 100644 (file)
index 0000000..3d27715
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR tree-optimization/87895 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O1" } */
+
+#include "pr87895-1.c"
diff --git a/gcc/testsuite/gcc.dg/gomp/pr87895-3.c b/gcc/testsuite/gcc.dg/gomp/pr87895-3.c
new file mode 100644 (file)
index 0000000..382ad6d
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR tree-optimization/87895 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O2" } */
+
+#pragma omp declare simd
+int foo (int x) __attribute__((noreturn));
+
+#pragma omp declare simd
+int
+bar (int x, int y)
+{
+  if (y == 1)
+    foo (x + 2);
+  if (y == 10)
+    foo (x + 6);
+  if (y != 25)
+    return 4;
+}