From: Richard Biener Date: Thu, 19 Nov 2020 08:06:50 +0000 (+0100) Subject: tree-optimization/97897 - complex lowering on abnormal edges X-Git-Tag: releases/gcc-10.3.0~259 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9272936ac5fac472a3690145572afa6ed19eaa8e;p=thirdparty%2Fgcc.git 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 PR tree-optimization/97897 * tree-complex.c (complex_propagate::visit_stmt): Make sure abnormally used SSA names are VARYING. (complex_propagate::visit_phi): Likewise. * gcc.dg/pr97897.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/pr97897.c b/gcc/testsuite/gcc.dg/pr97897.c new file mode 100644 index 000000000000..084c1cdbfebf --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97897.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +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 aa7288b008ba..6a7b31d00198 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)