public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR80713
Date: Fri, 12 May 2017 09:12:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.20.1705121110110.20726@zhemvz.fhfr.qr> (raw)


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;
+	  }
+    }
+}

                 reply	other threads:[~2017-05-12  9:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.20.1705121110110.20726@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).