Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-06-19  Richard Biener  <rguent...@suse.de>

        PR middle-end/81118
        * tree-cfgcleanup.c (cleanup_tree_cfg_noloop): Clear niter
        estimates if we changed anything.

        * gcc.dg/torture/pr81118.c: New testcase.

Index: gcc/tree-cfgcleanup.c
===================================================================
--- gcc/tree-cfgcleanup.c       (revision 249358)
+++ gcc/tree-cfgcleanup.c       (working copy)
@@ -839,7 +839,12 @@ cleanup_tree_cfg_noloop (void)
   timevar_pop (TV_TREE_CLEANUP_CFG);
 
   if (changed && current_loops)
-    loops_state_set (LOOPS_NEED_FIXUP);
+    {
+      /* Removing edges and/or blocks may make recorded bounds refer
+         to stale GIMPLE stmts now, so clear them.  */
+      free_numbers_of_iterations_estimates (cfun);
+      loops_state_set (LOOPS_NEED_FIXUP);
+    }
 
   return changed;
 }
Index: gcc/testsuite/gcc.dg/torture/pr81118.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr81118.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr81118.c      (working copy)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w" } */
+
+int a[7], b;
+int c()
+{
+  int d, e;
+  for (; d; d++)
+    if (a[d])
+      if (b)
+       return;
+      else if (d >= e)
+       return 0;
+}

Reply via email to