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


The following fixes up my earlier change in PRE for fallout with the
intricate interaction of the two "DCE" algorithms in PRE...

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2017-05-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80713
	* tree-ssa-pre.c (remove_dead_inserted_code): Clear
	inserted_exprs bit for not removed stmts.

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

Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c	(revision 247952)
+++ gcc/tree-ssa-pre.c	(working copy)
@@ -4947,8 +4947,14 @@ remove_dead_inserted_code (void)
 	}
     }
 
+  unsigned int to_clear = -1U;
   EXECUTE_IF_SET_IN_BITMAP (inserted_exprs, 0, i, bi)
     {
+      if (to_clear != -1U)
+	{
+	  bitmap_clear_bit (inserted_exprs, to_clear);
+	  to_clear = -1U;
+	}
       t = SSA_NAME_DEF_STMT (ssa_name (i));
       if (!gimple_plf (t, NECESSARY))
 	{
@@ -4969,7 +4975,14 @@ remove_dead_inserted_code (void)
 	      release_defs (t);
 	    }
 	}
+      else
+	/* eliminate_fini will skip stmts marked for removal if we
+	   already removed it and uses inserted_exprs for this, so
+	   clear those we didn't end up removing.  */
+	to_clear = i;
     }
+  if (to_clear != -1U)
+    bitmap_clear_bit (inserted_exprs, to_clear);
   BITMAP_FREE (worklist);
 }
 
Index: gcc/testsuite/gcc.dg/torture/pr80713.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr80713.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr80713.c	(working copy)
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+
+int a, b, d, e, f;
+int *c;
+void g()
+{
+  for (;;)
+    {
+      if (*c) {
+	  int h;
+	  *c = &h;
+      } else
+	b = 0;
+      if (f)
+	*c = g;
+      else
+	for (; a; a++)
+	  for (;;) {
+	      if (d)
+		break;
+	      c = e;
+	  }
+    }
+}

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

only message in thread, other threads:[~2017-05-12  9:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-12  9:12 [PATCH] Fix PR80713 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).