http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58997
Bug ID: 58997 Summary: ICE on valid code at -O3 on x86_64-linux-gnu (affecting gcc trunk and 4.8.2) Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The following code causes an ICE when compiled with the current gcc trunk and 4.8.2 at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes). It is a regression from 4.8.1. $ 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.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror --enable-checking=release --with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk Thread model: posix gcc version 4.9.0 20131105 (experimental) [trunk revision 204377] (GCC) $ $ gcc-trunk -O2 small.c; a.out $ gcc-4.8.1 -O3 small.c; a.out $ $ gcc-trunk -O3 small.c small.c: In function ‘foo’: small.c:18:1: internal compiler error: in simplify_subreg, at simplify-rtx.c:5901 } ^ 0x82fdca simplify_subreg(machine_mode, rtx_def*, machine_mode, unsigned int) ../../gcc-trunk/gcc/simplify-rtx.c:5900 0x830169 simplify_gen_subreg(machine_mode, rtx_def*, machine_mode, unsigned int) ../../gcc-trunk/gcc/simplify-rtx.c:6121 0x74a138 iv_subreg ../../gcc-trunk/gcc/loop-iv.c:439 0x74a138 iv_analyze_op ../../gcc-trunk/gcc/loop-iv.c:1164 0x74a257 iv_analyze_expr(rtx_def*, rtx_def*, machine_mode, rtx_iv*) ../../gcc-trunk/gcc/loop-iv.c:971 0x74a8c4 iv_analyze_def ../../gcc-trunk/gcc/loop-iv.c:1122 0x749fea iv_analyze_op ../../gcc-trunk/gcc/loop-iv.c:1193 0x7516ef may_unswitch_on ../../gcc-trunk/gcc/loop-unswitch.c:201 0x7516ef unswitch_single_loop ../../gcc-trunk/gcc/loop-unswitch.c:324 0x751c9c unswitch_single_loop ../../gcc-trunk/gcc/loop-unswitch.c:379 0x751f30 unswitch_loops() ../../gcc-trunk/gcc/loop-unswitch.c:148 0x742cb7 rtl_unswitch ../../gcc-trunk/gcc/loop-init.c:537 0x742cb7 execute ../../gcc-trunk/gcc/loop-init.c:567 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. $ $ gcc-4.8.2 -O3 small.c; a.out small.c: In function ‘foo’: small.c:18:1: internal compiler error: in simplify_subreg, at simplify-rtx.c:5732 } ^ 0x7bf858 simplify_subreg(machine_mode, rtx_def*, machine_mode, unsigned int) ../../gcc-4.8.2/gcc/simplify-rtx.c:5731 0x7c5c18 simplify_gen_subreg(machine_mode, rtx_def*, machine_mode, unsigned int) ../../gcc-4.8.2/gcc/simplify-rtx.c:5952 0x6f6438 iv_subreg ../../gcc-4.8.2/gcc/loop-iv.c:428 0x6f6438 iv_analyze_op ../../gcc-4.8.2/gcc/loop-iv.c:1154 0x6f5a2a iv_analyze_expr(rtx_def*, rtx_def*, machine_mode, rtx_iv*) ../../gcc-4.8.2/gcc/loop-iv.c:961 0x6f6094 iv_analyze_def ../../gcc-4.8.2/gcc/loop-iv.c:1112 0x6f62ea iv_analyze_op ../../gcc-4.8.2/gcc/loop-iv.c:1183 0x6fce35 may_unswitch_on ../../gcc-4.8.2/gcc/loop-unswitch.c:201 0x6fce35 unswitch_single_loop ../../gcc-4.8.2/gcc/loop-unswitch.c:324 0x6fd3f4 unswitch_single_loop ../../gcc-4.8.2/gcc/loop-unswitch.c:379 0x6fd628 unswitch_loops() ../../gcc-4.8.2/gcc/loop-unswitch.c:148 0x6f00a7 rtl_unswitch ../../gcc-4.8.2/gcc/loop-init.c:453 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, e; short d; char h; int foo () { for (; b;) { d = a ? c : 1 % a; c = d; h = d; if (!h) for (; e;) ; } return 0; } int main () { foo (); return 0; }