From: Richard Biener Date: Wed, 29 Aug 2018 14:13:20 +0000 (+0000) Subject: re PR tree-optimization/87132 (Gcc miscompiles at -O2 on valid code) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f70fdc31a7b0099e7322d0aba94830fb08f4c88;p=gcc.git re PR tree-optimization/87132 (Gcc miscompiles at -O2 on valid code) 2018-08-29 Richard Biener PR tree-optimization/87132 * tree-ssa-alias.c (get_continuation_for_phi): Do not translate when skipping defs reachable over backedges. * gcc.dg/torture/pr87132.c: New testcase. From-SVN: r263959 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 02a7b94d1f2..91a06ed7a16 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-29 Richard Biener + + PR tree-optimization/87132 + * tree-ssa-alias.c (get_continuation_for_phi): Do not translate + when skipping defs reachable over backedges. + 2018-08-29 Richard Biener * tree-core.h: Document use of deprecated_flag in SSA_NAME. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ebdfcf5904a..d785c903497 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-29 Richard Biener + + PR tree-optimization/87132 + * gcc.dg/torture/pr87132.c: New testcase. + 2018-08-29 David Malcolm PR c++/85110 diff --git a/gcc/testsuite/gcc.dg/torture/pr87132.c b/gcc/testsuite/gcc.dg/torture/pr87132.c new file mode 100644 index 00000000000..48b8673bba3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr87132.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ + +extern void abort (void); +int c, d; +int main() +{ + int e[] = {4, 4, 4, 4, 4, 4, 4, 4, 4}; + d = 8; + for (; d; d--) + for (int a = 0; a <= 8; a++) + { + c = e[1]; + e[d] = 0; + } + if (c != 0) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 6efe4c3a4a7..032e79b8ba0 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -2740,7 +2740,14 @@ next:; if (arg1 == arg0) ; else if (! maybe_skip_until (phi, arg0, ref, arg1, cnt, visited, - abort_on_visited, translate, data)) + abort_on_visited, + /* Do not translate when walking over + backedges. */ + dominated_by_p + (CDI_DOMINATORS, + gimple_bb (SSA_NAME_DEF_STMT (arg1)), + phi_bb) + ? NULL : translate, data)) return NULL_TREE; }