Created attachment 24663 [details] Output of "ajo-gcc -O1 -fno-tree-fre -c test.c -v" This failure reproduces for me with svn revision 175547 (2011-06-27), and also with GCC 4.5.1, but not with 4.4.5. I'm on Ubuntu 10.10, x86-64. cat >test.c <<EOF extern int g_27, g_115; void func_1(int x) { g_27 = 2; g_115 = 0; g_115 = (g_27 && ((g_27 = 1, 0 >= g_115) || (short)(x + (g_115 & x)))); } EOF gcc -O1 -fno-tree-fre -c test.c test.c: In function ‘func_1’: test.c:5:1: internal compiler error: in simplify_subreg, at simplify-rtx.c:5362 GCC 4.5.1 also ICEs on this input. The line number in 4.5.1 is simplify-rtx.c:5140. This test case is reduced from the output of Csmith 2.1.0 (git hash 01aa8b04, https://github.com/Quuxplusone/csmith/), using the following command line: csmith --no-paranoid --longlong --no-pointers --no-arrays --no-jumps --no-consts --no-volatiles --checksum --no-divs --no-muls --bitfields --packed-struct -s 1343472353
Confirmed.
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145494
The problem is that simplify_gen_binary (IOR, mode, ....); can simplify into anything, in this case into a (subreg:HI (reg:SI ...) 0), so we really don't know the argument of its first operand. It could be mode, but can be anything else too. I don't think it is actually useful to pass it at all though, if IOR was with two CONST_INT arguments, it would have been simplified into constant already by simplify_gen_binary.
Created attachment 24675 [details] gcc47-pr49619.patch Untested fix. The second part perhaps should be trunk only, not backported to the branches.
Author: jakub Date: Mon Jul 4 21:04:54 2011 New Revision: 175825 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175825 Log: PR rtl-optimization/49619 * combine.c (combine_simplify_rtx): In PLUS -> IOR simplification pass VOIDmode as op0_mode to recursive call, and return temp even when different from tor, just if it is not IOR of the original PLUS arguments. * gcc.dg/pr49619.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr49619.c Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c trunk/gcc/simplify-rtx.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Mon Jul 4 21:10:42 2011 New Revision: 175829 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175829 Log: PR rtl-optimization/49619 * combine.c (combine_simplify_rtx): In PLUS -> IOR simplification pass VOIDmode as op0_mode to recursive call, and return temp even when different from tor, just if it is not IOR of the original PLUS arguments. * gcc.dg/pr49619.c: New test. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr49619.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/combine.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Fixed for 4.6+ so far.
Author: jakub Date: Tue Jul 19 12:58:54 2011 New Revision: 176454 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176454 Log: Backport from mainline 2011-07-04 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/49619 * combine.c (combine_simplify_rtx): In PLUS -> IOR simplification pass VOIDmode as op0_mode to recursive call. * gcc.dg/pr49619.c: New test. Added: branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr49619.c Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/combine.c branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Author: jakub Date: Tue Jul 19 19:32:12 2011 New Revision: 176485 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176485 Log: Backport from mainline 2011-07-04 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/49619 * combine.c (combine_simplify_rtx): In PLUS -> IOR simplification pass VOIDmode as op0_mode to recursive call. * gcc.dg/pr49619.c: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr49619.c Modified: branches/gcc-4_4-branch/gcc/ChangeLog branches/gcc-4_4-branch/gcc/combine.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Fixed.