]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/80112 (ICE in doloop_condition_get at loop-doloop...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 08:20:03 +0000 (10:20 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 08:20:03 +0000 (10:20 +0200)
Backported from mainline
2017-03-24  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/80112
* loop-doloop.c (doloop_condition_get): Don't check condition
if cmp isn't SET with IF_THEN_ELSE src.

* gcc.dg/pr80112.c: New test.

From-SVN: r248664

gcc/ChangeLog
gcc/loop-doloop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr80112.c [new file with mode: 0644]

index 5ec64f66e44daf33e9c4889ff4119ce5b3ba2a73..106c41c0501433861fb54758e900346ccb46c66e 100644 (file)
@@ -1,6 +1,12 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-03-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/80112
+       * loop-doloop.c (doloop_condition_get): Don't check condition
+       if cmp isn't SET with IF_THEN_ELSE src.
+
        2017-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/80129
index 0b6447adedebd13a551fc6bd89efa7bfabefd487..221939a840ba43a3a322161d3a8b25e64d4256d8 100644 (file)
@@ -179,10 +179,13 @@ doloop_condition_get (rtx doloop_pat)
        }
       else
         inc = PATTERN (prev_insn);
-      /* We expect the condition to be of the form (reg != 0)  */
-      cond = XEXP (SET_SRC (cmp), 0);
-      if (GET_CODE (cond) != NE || XEXP (cond, 1) != const0_rtx)
-        return 0;
+      if (GET_CODE (cmp) == SET && GET_CODE (SET_SRC (cmp)) == IF_THEN_ELSE)
+       {
+         /* We expect the condition to be of the form (reg != 0)  */
+         cond = XEXP (SET_SRC (cmp), 0);
+         if (GET_CODE (cond) != NE || XEXP (cond, 1) != const0_rtx)
+           return 0;
+       }
     }
   else
     {
index d1080804767ccca68f97ce2ae98eeae98ff0f271..44a06cdd1f9b6233fb663171809f3c8b730f647d 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-03-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/80112
+       * gcc.dg/pr80112.c: New test.
+
        2017-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/80141
diff --git a/gcc/testsuite/gcc.dg/pr80112.c b/gcc/testsuite/gcc.dg/pr80112.c
new file mode 100644 (file)
index 0000000..7c78aae
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/80112 */
+/* { dg-do compile } */
+/* { dg-options "-Os -fmodulo-sched" } */
+
+void **a;
+
+void
+foo (int c)
+{
+  void *d[] = {&&e, &&f};
+  a = d;
+  switch (c)
+    {
+    f:
+      c = 9;
+      /* FALLTHRU */
+    case 9:
+      goto *a++;
+    e:;
+    }
+}