From a5e8b0607431fdefa0dba2bcf477a1695ac5d227 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 3 Sep 2018 17:41:05 +0000 Subject: [PATCH] re PR tree-optimization/87177 (wrong code at -O2 and -O3 on x86-64-linux-gnu) 2018-09-03 Richard Biener PR tree-optimization/87177 * tree-ssa-sccvn.c (vuse_ssa_val): Revert previous change, keep cleanup. * gcc.dg/torture/pr87177.c: New testcase. * gcc.dg/torture/pr87177-2.c: Likewise. From-SVN: r264069 --- gcc/ChangeLog | 6 +++ gcc/testsuite/ChangeLog | 6 +++ gcc/testsuite/gcc.dg/torture/pr87177-2.c | 28 +++++++++++ gcc/testsuite/gcc.dg/torture/pr87177.c | 61 ++++++++++++++++++++++++ gcc/tree-ssa-sccvn.c | 12 +---- 5 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr87177-2.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr87177.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e6791fd8dba..62e32c68774 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-09-03 Richard Biener + + PR tree-optimization/87177 + * tree-ssa-sccvn.c (vuse_ssa_val): Revert previous change, keep + cleanup. + 2018-09-03 Alexander Monakov * bb-reorder.c (edge_order): Convert to C-qsort-style diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b44c714d7d2..9828b4b94df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-09-03 Richard Biener + + PR tree-optimization/87177 + * gcc.dg/torture/pr87177.c: New testcase. + * gcc.dg/torture/pr87177-2.c: Likewise. + 2018-09-03 Richard Biener PR tree-optimization/87200 diff --git a/gcc/testsuite/gcc.dg/torture/pr87177-2.c b/gcc/testsuite/gcc.dg/torture/pr87177-2.c new file mode 100644 index 00000000000..55920768c83 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr87177-2.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +int dk; + +void +lv (void) +{ + int nm; + + dk = 1; + while (dk != 0) + { + } + + if (1 / 0) + { + dk = 0; + while (dk != 0) + { + } + } + + for (;;) + nm = !!dk; + + (void) nm; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr87177.c b/gcc/testsuite/gcc.dg/torture/pr87177.c new file mode 100644 index 00000000000..efeaebf301c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr87177.c @@ -0,0 +1,61 @@ +/* { dg-do run } */ + +int __attribute__((noinline)) my_printf (const char *p, ...) +{ + static volatile int x; + ++x; +} + +int a, b, c, e, f, g, h, i, j, k, l; +unsigned d; + +static void p () +{ + while (1) + { + int n = h; + h = 8; + if (!e) + break; + h = n; + while (1) + ; + } + for (; c != 4; c++) + { + int o = g = 1; + for (; g; g--) + { + while (d < b) + e--; + a = g; + int q = o; + if (q) + L1: + j = f; + if (l) + { + my_printf ("%d", g); + goto L1; + } + o = l; + k = q; + } + } +} + +void s () +{ + int m = 0; +L2: + if (i && g) + goto L2; + for (; m < 2; m++) + p (); +} + +int main () +{ + s (); + return 0; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 1f003358851..34c193b58f5 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -485,16 +485,8 @@ vuse_ssa_val (tree x) do { - if (SSA_NAME_IS_DEFAULT_DEF (x)) - return x; - vn_ssa_aux_t tem - = vn_ssa_aux_hash->find_with_hash (x, SSA_NAME_VERSION (x)); - /* For region-based VN this makes walk_non_aliased_vuses stop walking - when we are about to look at a def outside of the region. */ - if (!tem || !tem->visited) - return NULL_TREE; - gcc_assert (tem->valnum != VN_TOP); - x = tem->valnum; + x = SSA_VAL (x); + gcc_assert (x != VN_TOP); } while (SSA_NAME_IN_FREE_LIST (x)); -- 2.30.2