[gcc r11-5156] tree-optimization/97897 - complex lowering on abnormal edges

Richard Biener rguenth@gcc.gnu.org
Thu Nov 19 08:57:56 GMT 2020


https://gcc.gnu.org/g:0d8290959ecf2c5f1dd062e57782b5e91be0f8f6

commit r11-5156-g0d8290959ecf2c5f1dd062e57782b5e91be0f8f6
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Nov 19 09:06:50 2020 +0100

    tree-optimization/97897 - complex lowering on abnormal edges
    
    This fixes complex lowering to not put constants into abnormal
    edge PHI values by making sure abnormally used SSA names are
    VARYING in its propagation lattice.
    
    2020-11-19  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/97897
            * tree-complex.c (complex_propagate::visit_stmt): Make sure
            abnormally used SSA names are VARYING.
            (complex_propagate::visit_phi): Likewise.
            * tree-ssa.c (verify_phi_args): Verify PHI arguments on abnormal
            edges are SSA names.
    
            * gcc.dg/pr97897.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/pr97897.c | 13 +++++++++++++
 gcc/tree-complex.c             |  5 ++++-
 gcc/tree-ssa.c                 |  6 ++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr97897.c b/gcc/testsuite/gcc.dg/pr97897.c
new file mode 100644
index 00000000000..775f34ca767
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97897.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+void h ();
+void f () __attribute__ ((returns_twice));
+void g (_Complex int a)
+{
+  f ();
+  if (a != 0)
+  {
+    a = 0;
+    h ();
+  }
+}
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index f132e0f41c7..1cfb3e8d743 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -318,7 +318,7 @@ complex_propagate::visit_stmt (gimple *stmt, edge *taken_edge_p ATTRIBUTE_UNUSED
 
   lhs = gimple_get_lhs (stmt);
   /* Skip anything but GIMPLE_ASSIGN and GIMPLE_CALL with a lhs.  */
-  if (!lhs)
+  if (!lhs || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
     return SSA_PROP_VARYING;
 
   /* These conditions should be satisfied due to the initial filter
@@ -417,6 +417,9 @@ complex_propagate::visit_phi (gphi *phi)
      set up in init_dont_simulate_again.  */
   gcc_assert (TREE_CODE (TREE_TYPE (lhs)) == COMPLEX_TYPE);
 
+  if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
+    return SSA_PROP_VARYING;
+
   /* We've set up the lattice values such that IOR neatly models PHI meet.  */
   new_l = UNINITIALIZED;
   for (i = gimple_phi_num_args (phi) - 1; i >= 0; --i)
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index c47b963bbb2..b44361f8244 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -987,6 +987,12 @@ verify_phi_args (gphi *phi, basic_block bb, basic_block *definition_block)
 	  err = true;
 	}
 
+      if ((e->flags & EDGE_ABNORMAL) && TREE_CODE (op) != SSA_NAME)
+	{
+	  error ("PHI argument on abnormal edge is not SSA_NAME");
+	  err = true;
+	}
+
       if (TREE_CODE (op) == SSA_NAME)
 	{
 	  err = verify_ssa_name (op, virtual_operand_p (gimple_phi_result (phi)));


More information about the Gcc-cvs mailing list