From 897da3034cc2b1e3675d891e833c6b2a02fd4fe5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 15 Sep 2017 09:19:36 +0000 Subject: [PATCH] re PR tree-optimization/82217 (ICE on valid code at -O1 and above: in visit_phi, at tree-ssa-sccvn.c:3908) 2017-09-15 Richard Biener PR tree-optimization/82217 * tree-ssa-sccvn.c (visit_phi): Properly handle all VN_TOP but not undefined case. * gcc.dg/torture/pr82217.c: New testcase. From-SVN: r252796 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/torture/pr82217.c | 32 ++++++++++++++++++++++++++ gcc/tree-ssa-sccvn.c | 9 +++----- 4 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr82217.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4711d4e16c1..65bfc163f5a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-09-15 Richard Biener + + PR tree-optimization/82217 + * tree-ssa-sccvn.c (visit_phi): Properly handle all VN_TOP + but not undefined case. + 2017-09-15 Jakub Jelinek PR target/82145 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b47923b3802..cd3f7a96c0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-15 Richard Biener + + PR tree-optimization/82217 + * gcc.dg/torture/pr82217.c: New testcase. + 2017-09-15 Jakub Jelinek PR target/82145 diff --git a/gcc/testsuite/gcc.dg/torture/pr82217.c b/gcc/testsuite/gcc.dg/torture/pr82217.c new file mode 100644 index 00000000000..471f474aab3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr82217.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +int a, b, c; + +void fn1 () +{ + while (1) + { + if (c) + goto L2; + break; + } + if (c) + { +L1: + { + int g[1]; + if (b) + goto L1; + goto L1; +L2: + for (a = 0; a;) + goto L1; + } + } +} + +int main () +{ + fn1 (); + return 0; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 44618daedce..0b0c5106d30 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -3901,13 +3901,10 @@ visit_phi (gimple *phi) if only a single edge is exectuable use its value. */ if (n_executable <= 1) result = seen_undef ? seen_undef : sameval; - /* If we saw only undefined values create a new undef SSA name to - avoid false equivalences. */ + /* If we saw only undefined values and VN_TOP use one of the + undefined values. */ else if (sameval == VN_TOP) - { - gcc_assert (seen_undef); - result = seen_undef; - } + result = seen_undef ? seen_undef : sameval; /* First see if it is equivalent to a phi node in this block. We prefer this as it allows IV elimination - see PRs 66502 and 67167. */ else if ((result = vn_phi_lookup (phi))) -- 2.30.2