The following code causes an ICE when compiled with the current gcc trunk at -O3 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/5.0.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 5.0.0 20141117 (experimental) [trunk revision 217671] (GCC) $ gcc-trunk -O2 -c small.c $ gcc-4.9 -O3 -c small.c $ $ gcc-trunk -O3 -c small.c small.c: In function ‘fn1’: small.c:4:1: internal compiler error: in add_to_predicate_list, at tree-if-conv.c:438 fn1 () ^ 0xb11044 add_to_predicate_list ../../gcc-trunk/gcc/tree-if-conv.c:438 0xb11044 add_to_dst_predicate_list ../../gcc-trunk/gcc/tree-if-conv.c:488 0xb11564 predicate_bbs ../../gcc-trunk/gcc/tree-if-conv.c:1155 0xb11c7a combine_blocks ../../gcc-trunk/gcc/tree-if-conv.c:2005 0xb13c06 tree_if_conversion ../../gcc-trunk/gcc/tree-if-conv.c:2162 0xb13c06 execute ../../gcc-trunk/gcc/tree-if-conv.c:2240 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. $ ------------------------------- int a, b, c, d[1], e, f, g, h; void fn1 () { char i = 0; for (b = 0; b >= 0;) for (b = 0; b < 2; b++) { d[f] && (e = 0); h = 1 & a - i ? 0 : a; c = i = h; char j = c; int k = 0; g = j || j > k; d[0] = 0; } }
It was caused by r217277.
My patch is responsible for ICE - I did not assume that before if-convert phase cfg may contain redundant degenerative conditional branches: <bb 4>: ... _14 = d[pretmp_51]; if (_14 != 0) goto <bb 6>; else goto <bb 5>; } bb_5 (preds = {bb_4 }, succs = {bb_6 }) { <bb 5>: } bb_6 (preds = {bb_5 bb_4 }, succs = {bb_10 bb_7 }) I deleted wrong assert and slightly changed code to set up predicate for join bb conditionally. With this fix test is compiled successfully. The patch was sent to GCC community for review.
Author: ienkovich Date: Mon Dec 1 12:19:28 2014 New Revision: 218206 URL: https://gcc.gnu.org/viewcvs?rev=218206&root=gcc&view=rev Log: gcc/ PR tree-optimization/63941 * tree-if-conv.c (add_to_predicate_list): Delete wrong assertion that DOM_BB has non-true predicate, conditionally set non-true predicate for BB. gcc/testsuite/ PR tree-optimization/63941 * gcc.dg/torture/pr63941.c: New test. Added: trunk/gcc/testsuite/gcc.dg/torture/pr63941.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-if-conv.c
Fixed.