This reverts vuse_ssa_val back to its previous state. I need to think about how to limit alias walking for regions but will do so as followup.
Bootstrap & regtest running on x86_64-unknown-linux-gnu. Richard. 2018-09-03 Richard Biener <rguent...@suse.de> 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. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 264049) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -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)); Index: gcc/testsuite/gcc.dg/torture/pr87177.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr87177.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr87177.c (working copy) @@ -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; +} Index: gcc/testsuite/gcc.dg/torture/pr87177-2.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr87177-2.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr87177-2.c (working copy) @@ -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; +}