From 29545149bf8ca8c89a9a7d32fe7fdb8e9294759c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 12 Sep 2017 14:15:37 +0000 Subject: [PATCH] re PR tree-optimization/82157 (ICE on valid code at -O2 and -O3: cannot update SSA form) 2017-09-12 Richard Biener PR tree-optimization/82157 * tree-ssa-pre.c (remove_dead_inserted_code): Do not remove stmts with side-effects. * gcc.dg/torture/pr82157.c: New testcase. From-SVN: r252020 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/torture/pr82157.c | 43 ++++++++++++++++++++++++++ gcc/tree-ssa-pre.c | 2 ++ 4 files changed, 56 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr82157.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7bc95e86c94..62e8fae4128 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-09-12 Richard Biener + + PR tree-optimization/82157 + * tree-ssa-pre.c (remove_dead_inserted_code): Do not remove + stmts with side-effects. + 2017-09-12 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5d81c587e9c..57226399b77 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-12 Richard Biener + + PR tree-optimization/82157 + * gcc.dg/torture/pr82157.c: New testcase. + 2017-09-12 Simon Atanasyan * gcc.target/mips/near-far-1.c: Add check for 'short_call' diff --git a/gcc/testsuite/gcc.dg/torture/pr82157.c b/gcc/testsuite/gcc.dg/torture/pr82157.c new file mode 100644 index 00000000000..036b484f3ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr82157.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ + +int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; + +int aa () +{ + w = f < 0 || e >> f; + while (z) + h = i && (r && p) | ((l = p) == c % d); + k = v + 1 < a; + t = -(j < 1) * q; + return u; +} + +int ab () +{ + for (j = 0; 1; j = 5) + if (!s) + return d; +} + +void ac () +{ + char ad = aa (); + ab (); + if (x) + { + for (m = 0; m < 3; m = a) + { + y = a && b; + if (g) + break; + } + n = j; + } + o = j & ad; +} + +int main () +{ + ac (); + return 0; +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 6f9fac5b9a0..364272ddf0e 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4913,6 +4913,8 @@ remove_dead_inserted_code (void) continue; gimple *t = SSA_NAME_DEF_STMT (def); + if (gimple_has_side_effects (t)) + continue; /* Add uses to the worklist. */ ssa_op_iter iter; -- 2.30.2