public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR81118
@ 2017-06-19 15:06 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2017-06-19 15:06 UTC (permalink / raw)
  To: gcc-patches


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

Richard.

2017-06-19  Richard Biener  <rguenther@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;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-19 15:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-19 15:06 [PATCH] Fix PR81118 Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).