public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10099] tree-optimization/101394 - fix PRE full redundancy wrt abnormals
@ 2021-09-06 10:18 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-09-06 10:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:424737442fb7cd6ea8f0e63098c26cebdaf82a51

commit r10-10099-g424737442fb7cd6ea8f0e63098c26cebdaf82a51
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jul 12 10:49:03 2021 +0200

    tree-optimization/101394 - fix PRE full redundancy wrt abnormals
    
    This avoids adding a copy from an abnormal picked up from PHI
    translation much like we'd avoid inserting the translated
    expression on pred edges.
    
    2021-07-12  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/101394
            * tree-ssa-pre.c (do_pre_regular_insertion): Avoid inserting
            copies from abnormals for a full redundancy.
    
            * gcc.dg/torture/pr101394.c: New testcase.
    
    (cherry picked from commit 92343e0ba4d47f21ae20ffcb83d736bdbc15dae0)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr101394.c | 18 ++++++++++++++++++
 gcc/tree-ssa-pre.c                      |  6 +++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr101394.c b/gcc/testsuite/gcc.dg/torture/pr101394.c
new file mode 100644
index 00000000000..87fbdadc152
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr101394.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int a, b, c, d;
+void h();
+int e() __attribute__((returns_twice));
+void f() {
+  int *g = (int *)(__INTPTR_TYPE__)c;
+  if (b) {
+    h();
+    g--;
+    if (a)
+      if (d)
+        h();
+  }
+  if (g++)
+    e();
+  c = (__INTPTR_TYPE__)g;
+}
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 82fc364b036..b406eadf080 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3312,7 +3312,11 @@ do_pre_regular_insertion (basic_block block, basic_block dom)
 	  /* If all edges produce the same value and that value is
 	     an invariant, then the PHI has the same value on all
 	     edges.  Note this.  */
-	  else if (!cant_insert && all_same)
+	  else if (!cant_insert
+		   && all_same
+		   && (edoubleprime->kind != NAME
+		       || !SSA_NAME_OCCURS_IN_ABNORMAL_PHI
+			     (PRE_EXPR_NAME (edoubleprime))))
 	    {
 	      gcc_assert (edoubleprime->kind == CONSTANT
 			  || edoubleprime->kind == NAME);


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

only message in thread, other threads:[~2021-09-06 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 10:18 [gcc r10-10099] tree-optimization/101394 - fix PRE full redundancy wrt abnormals 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).