re PR tree-optimization/90716 (gcc generates wrong debug information at -O2)
authorRichard Biener <rguenther@suse.de>
Mon, 3 Jun 2019 10:17:16 +0000 (10:17 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 3 Jun 2019 10:17:16 +0000 (10:17 +0000)
2019-06-03  Richard Biener  <rguenther@suse.de>

PR tree-optimization/90716
* tree-loop-distribution.c (destroy_loop): Process blocks in
correct order.

* gcc.dg/guality/pr90716.c: New testcase.

From-SVN: r271858

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/pr90716.c [new file with mode: 0644]
gcc/tree-loop-distribution.c

index f887329..7aabe88 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/90716
+       * tree-loop-distribution.c (destroy_loop): Process blocks in
+       correct order.
+
 2019-06-03  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        PR target/88837
index 93b1f09..75e38b8 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/90716
+       * gcc.dg/guality/pr90716.c: New testcase.
+
 2019-06-03  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        PR target/88837
diff --git a/gcc/testsuite/gcc.dg/guality/pr90716.c b/gcc/testsuite/gcc.dg/guality/pr90716.c
new file mode 100644 (file)
index 0000000..b2f5c9d
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+void __attribute__((noinline))
+optimize_me_not ()
+{
+  __asm__ volatile ("" : : : "memory");
+}
+int a[7][8];
+int main()
+{
+  int b, j;
+  b = 0;
+  for (; b < 7; b++) {
+      j = 0;
+      for (; j < 8; j++)
+       a[b][j] = 0;
+  }
+  /* j may very well be optimized out, so we cannot test for j == 8.
+     Instead test j + 1 which will make the test UNSUPPORTED if i
+     is optimized out.  Since the test previously had wrong debug
+     with j == 0 this is acceptable.  */
+  optimize_me_not(); /* { dg-final { gdb-test . "j + 1" "9" } } */
+  return 0;
+}
index b2f2fd2..88f8e7a 100644 (file)
@@ -1104,15 +1104,13 @@ destroy_loop (struct loop *loop)
 
   gimple_stmt_iterator dst_gsi = gsi_after_labels (exit->dest);
   bool safe_p = single_pred_p (exit->dest);
-  i = nbbs;
-  do
+  for (unsigned i = 0; i < nbbs; ++i)
     {
       /* We have made sure to not leave any dangling uses of SSA
          names defined in the loop.  With the exception of virtuals.
         Make sure we replace all uses of virtual defs that will remain
         outside of the loop with the bare symbol as delete_basic_block
         will release them.  */
-      --i;
       for (gphi_iterator gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi);
           gsi_next (&gsi))
        {
@@ -1147,7 +1145,6 @@ destroy_loop (struct loop *loop)
            gsi_next (&gsi);
        }
     }
-  while (i != 0);
 
   redirect_edge_pred (exit, src);
   exit->flags &= ~(EDGE_TRUE_VALUE|EDGE_FALSE_VALUE);