[gcc r13-1963] middle-end: Fix phi-ssa assertion triggers. [PR106519]

Tamar Christina tnfchris@gcc.gnu.org
Thu Aug 4 15:36:03 GMT 2022


https://gcc.gnu.org/g:c832ec4c3ec4853ad89ff3b0dbf6e9454e75e8cc

commit r13-1963-gc832ec4c3ec4853ad89ff3b0dbf6e9454e75e8cc
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Thu Aug 4 16:35:31 2022 +0100

    middle-end: Fix phi-ssa assertion triggers.  [PR106519]
    
    For the diamond PHI form in tree_ssa_phiopt_worker we need to
    extract edge e2 sooner.  This changes it so we extract it at the
    same time we determine we have a diamond shape.
    
    gcc/ChangeLog:
    
            PR middle-end/106519
            * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Check final phi edge for
            diamond shapes.
    
    gcc/testsuite/ChangeLog:
    
            PR middle-end/106519
            * gcc.dg/pr106519.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/pr106519.c | 11 +++++++++++
 gcc/tree-ssa-phiopt.cc          |  6 ++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr106519.c b/gcc/testsuite/gcc.dg/pr106519.c
new file mode 100644
index 00000000000..3d4662d8a02
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106519.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+int bytestart, bytemem_0_0, modlookup_l_p;
+
+void
+modlookup_l() {
+  long j;
+  while (modlookup_l_p)
+    while (bytestart && j && bytemem_0_0)
+      j = j + 1;
+}
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index a8e55e04064..ef4c0b78f4e 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -269,7 +269,10 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	}
       else if (EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest
 	       && !empty_block_p (bb1))
-	diamond_p = true;
+	{
+	  diamond_p = true;
+	  e2 = EDGE_SUCC (bb2, 0);
+	}
       else
 	continue;
 
@@ -324,7 +327,6 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
 	  if (!candorest)
 	    continue;
 
-	  e2 = diamond_p ? EDGE_SUCC (bb2, 0) : e2;
 	  phi = single_non_singleton_phi_for_edges (phis, e1, e2);
 	  if (!phi)
 	    continue;


More information about the Gcc-cvs mailing list