Bug 49619 - [4.5 Regression] ICE in simplify_subreg, at simplify-rtx.c:5362
Summary: [4.5 Regression] ICE in simplify_subreg, at simplify-rtx.c:5362
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: 4.5.4
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-03 17:55 UTC by Arthur O'Dwyer
Modified: 2011-07-19 19:51 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work: 4.4.5
Known to fail: 4.5.1
Last reconfirmed: 2011-07-04 09:43:58


Attachments
Output of "ajo-gcc -O1 -fno-tree-fre -c test.c -v" (741 bytes, text/plain)
2011-07-03 17:55 UTC, Arthur O'Dwyer
Details
gcc47-pr49619.patch (804 bytes, patch)
2011-07-04 14:13 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur O'Dwyer 2011-07-03 17:55:01 UTC
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
Comment 1 Richard Biener 2011-07-04 09:43:58 UTC
Confirmed.
Comment 2 Jakub Jelinek 2011-07-04 10:30:10 UTC
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145494
Comment 3 Jakub Jelinek 2011-07-04 14:11:50 UTC
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.
Comment 4 Jakub Jelinek 2011-07-04 14:13:21 UTC
Created attachment 24675 [details]
gcc47-pr49619.patch

Untested fix.  The second part perhaps should be trunk only, not backported to the branches.
Comment 5 Jakub Jelinek 2011-07-04 21:04:57 UTC
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
Comment 6 Jakub Jelinek 2011-07-04 21:10:44 UTC
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
Comment 7 Jakub Jelinek 2011-07-04 21:16:33 UTC
Fixed for 4.6+ so far.
Comment 8 Jakub Jelinek 2011-07-19 12:58:57 UTC
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
Comment 9 Jakub Jelinek 2011-07-19 19:32:15 UTC
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
Comment 10 Jakub Jelinek 2011-07-19 19:51:32 UTC
Fixed.