From: Richard Biener Date: Tue, 6 Oct 2015 12:34:15 +0000 (+0000) Subject: re PR tree-optimization/67859 (ICE on valid code at -O2 and -O3 on x86_64-linux-gnu) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0580f6a1a8eba90a82c83b8341f94d25529b25e9;p=gcc.git re PR tree-optimization/67859 (ICE on valid code at -O2 and -O3 on x86_64-linux-gnu) 2015-10-06 Richard Biener PR tree-optimization/67859 * tree-ssa-pre.c (create_expression_by_pieces): Properly discard not inserted stmts. * gcc.dg/torture/pr67859.c: New testcase. From-SVN: r228519 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6afa6910260..eb02d8b6c1c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-10-06 Richard Biener + + PR tree-optimization/67859 + * tree-ssa-pre.c (create_expression_by_pieces): Properly + discard not inserted stmts. + 2015-10-06 Jonathan Wakely * doc/extend.texi (Template Instantiation): Reorder options and diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a931b24adc9..8b27d2ec97f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-06 Richard Biener + + PR tree-optimization/67859 + * gcc.dg/torture/pr67859.c: New testcase. + 2015-10-05 Kirill Yukhin * gcc.target/i386/builtin_target.c: Add check for AES and PCLMUL. diff --git a/gcc/testsuite/gcc.dg/torture/pr67859.c b/gcc/testsuite/gcc.dg/torture/pr67859.c new file mode 100644 index 00000000000..259b3810f10 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr67859.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +int a, b, c; + +void +fn1 () +{ + b = c ? 0 : 1 << a; + b |= 0x9D7A5FD9; + for (;;) + { + int d = 1; + b &= (unsigned) d; + } +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index fb9ed02ec87..c5af63d8ca1 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2897,11 +2897,16 @@ create_expression_by_pieces (basic_block block, pre_expr expr, folded = gimple_convert (&forced_stmts, exprtype, folded); - /* If everything simplified to an exisiting SSA name or constant just - return that. */ - if (gimple_seq_empty_p (forced_stmts) - || is_gimple_min_invariant (folded)) + /* If there is nothing to insert, return the simplified result. */ + if (gimple_seq_empty_p (forced_stmts)) return folded; + /* If we simplified to a constant return it and discard eventually + built stmts. */ + if (is_gimple_min_invariant (folded)) + { + gimple_seq_discard (forced_stmts); + return folded; + } gcc_assert (TREE_CODE (folded) == SSA_NAME);