The following code causes an ICE when compiled with the current gcc trunk at -O1 and above on x86_64-linux-gnu in both 32-bit and 64-bit modes. It is a regression from 4.9.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 4.10.0 20140518 (experimental) [trunk revision 210581] (GCC) $ $ gcc-trunk -O0 -c small.c $ gcc-4.9.0 -O1 -c small.c $ $ gcc-trunk -O1 -c small.c small.c: In function ‘bar’: small.c:30:1: internal compiler error: Segmentation fault } ^ 0x988c1f crash_signal ../../gcc-trunk/gcc/toplev.c:337 0xa5b6de gimple_code ../../gcc-trunk/gcc/gimple.h:1405 0xa5b6de gimple_nop_p ../../gcc-trunk/gcc/gimple.h:5559 0xa5b6de walk_non_aliased_vuses(ao_ref*, tree_node*, void* (*)(ao_ref*, tree_node*, unsigned int, void*), void* (*)(ao_ref*, tree_node*, void*, bool), void*) ../../gcc-trunk/gcc/tree-ssa-alias.c:2550 0xb02599 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**) ../../gcc-trunk/gcc/tree-ssa-sccvn.c:2117 0xae040a eliminate_dom_walker::before_dom_children(basic_block_def*) ../../gcc-trunk/gcc/tree-ssa-pre.c:4285 0xe93527 dom_walker::walk(basic_block_def*) ../../gcc-trunk/gcc/domwalk.c:177 0xaddcad eliminate ../../gcc-trunk/gcc/tree-ssa-pre.c:4429 0xade193 execute ../../gcc-trunk/gcc/tree-ssa-pre.c:4852 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ --------------------------- void __assert_fail (void); int **a, b, c, e, *j; short *d, **f; int * foo () { *a = j; if (!(1 & e)) __assert_fail (); return 0; } void bar () { int *g = &b; short **h = &d; if ((f = &d) != h) for (; b;) { int i = 1; if (i) g = foo (); c = 0; } if (!g) __assert_fail (); }
Confirmed, mine.
Interesting ;) We do some non-sensical simplification on dead code and ICE. But our dead-CFG compute code in SCCVN isn't up to recognizing a dead loop because it's conservative and not optimistic. Ultimatively this all is because of replacing a call with sth that doesn't have a VDEF and gsi_replace/update_stmt being called which releases an SSA name which corrupts the value-numbering lattice.
Author: rguenth Date: Mon May 19 14:33:31 2014 New Revision: 210614 URL: http://gcc.gnu.org/viewcvs?rev=210614&root=gcc&view=rev Log: 2014-05-19 Richard Biener <rguenther@suse.de> PR tree-optimization/61221 * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Do nothing for unreachable blocks. * tree-ssa-sccvn.c (cond_dom_walker::before_dom_children): Improve unreachability detection. * gcc.dg/torture/pr61221.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr61221.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-pre.c trunk/gcc/tree-ssa-sccvn.c
Fixed (worked around, real fix in testing).
Author: rguenth Date: Tue May 20 08:16:13 2014 New Revision: 210633 URL: http://gcc.gnu.org/viewcvs?rev=210633&root=gcc&view=rev Log: 2014-05-20 Richard Biener <rguenther@suse.de> PR tree-optimization/61221 * tree-ssa-pre.c (el_to_update): Remove. (eliminate_dom_walker::before_dom_children): Handle released VDEFs by value-numbering them to the associated VUSE. Update stmt immediately for substituted call address. (eliminate): Remove delayed stmt updating code. * tree-ssa-sccvn.c (vuse_ssa_val): New function valueizing possibly late re-numbered vuses. (vn_reference_lookup_2): Adjust. (vn_reference_lookup_pieces): Likewise. (vn_reference_lookup): Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-pre.c trunk/gcc/tree-ssa-sccvn.c