re PR rtl-optimization/80112 (ICE in doloop_condition_get at loop-doloop.c:158)
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Mar 2017 13:37:01 +0000 (14:37 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 24 Mar 2017 13:37:01 +0000 (14:37 +0100)
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: r246441

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

index 8d4adfbb07fbcaa9a3275641d56d0087fe79e8ea..12525c649534d000906ecfece2ff8f9750443d7d 100644 (file)
@@ -1,3 +1,9 @@
+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-24  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR tree-optimization/80158
index 3b9a96034abe9120710f7acb441407924ab9aa58..3483000aa97cc1099a8e716f3c65623391f1242a 100644 (file)
@@ -153,10 +153,13 @@ doloop_condition_get (rtx_insn *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 5ab5619e8e125fbe832849c34e3cbf56e6faae78..a53ffefb6e36734989a64abab042542cff220d16 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/80112
+       * gcc.dg/pr80112.c: New test.
+
 2017-03-24  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * c-c++-common/Wimplicit-fallthrough-7.c: Adjust dg-warning
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:;
+    }
+}