This fixes a bootstrap compare failure on current mainline and 4.9
branch configured with --disable-checking, caused by losing value
range info when outputting debug info.  Lack of value range info leads
to loop bounds not being calculated, which in turn means a "j < n"
test is not converted to "j != n".  Details in the PR.

Bootstrapped and regression tested powerpc64-linux, and committed
with Jakub's approval.

gcc/
        PR bootstrap/61583
        * tree-vrp.c (remove_range_assertions): Do not set is_unreachable
        to zero on debug statements.
gcc/testsuite/
        * gcc.dg/pr61583.c: New.

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c      (revision 211886)
+++ gcc/tree-vrp.c      (working copy)
@@ -6523,8 +6523,9 @@ remove_range_assertions (void)
          }
        else
          {
+           if (!is_gimple_debug (gsi_stmt (si)))
+             is_unreachable = 0;
            gsi_next (&si);
-           is_unreachable = 0;
          }
       }
 }
Index: gcc/testsuite/gcc.dg/pr61583.c
===================================================================
--- gcc/testsuite/gcc.dg/pr61583.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr61583.c      (revision 0)
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+void
+f1 (int n, int b)
+{
+  extern void f2 (int);
+  int j;
+
+  if (b)
+    n = 1;
+
+  if (n < 1)
+    __builtin_unreachable ();
+
+  for (j = 0; j < n; j++)
+    f2 (j);
+}

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to