Bug 33655 - [4.3 Regression] ICE in bitfield_overlaps_p, at tree-sra.c:2901
Summary: [4.3 Regression] ICE in bitfield_overlaps_p, at tree-sra.c:2901
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Alexandre Oliva
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-10-04 12:18 UTC by Richard Biener
Modified: 2007-12-03 04:14 UTC (History)
4 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-10-05 15:24:19


Attachments
testcase (unreduced) (28.71 KB, application/octet-stream)
2007-10-04 12:19 UTC, Richard Biener
Details
add another conversion to bitsizetype (348 bytes, patch)
2007-10-08 22:19 UTC, Jim Wilson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2007-10-04 12:18:53 UTC
Building ncurses with trunk ICEs with:

/usr/bin/gcc -DHAVE_CONFIG_H -I../ncurses -I. -I. -I../include -D_GNU_SOURCE -DNDEBUG -O2 -g -fmessage-length=0 -pipe -D_REENTRANT -fPIC -c ../ncurses/./base/lib_addch.c -o ../obj_s/lib_addch.o
gcc-trunk: warning: -pipe ignored because -save-temps specified
../ncurses/./base/lib_addch.c: In function 'render_char':
../ncurses/./base/lib_addch.c:541: internal compiler error: in bitfield_overlaps_p, at tree-sra.c:2901
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

This was caused by

2007-10-01  Alexandre Oliva  <aoliva@redhat.com>

        PR middle-end/22156
        * tree-sra.c (struct sra_elt): Add in_bitfld_block.
        (sra_hash_tree): Handle BIT_FIELD_REFs.
        (sra_elt_hash): Don't hash bitfld blocks.
...
Comment 1 Richard Biener 2007-10-04 12:19:19 UTC
Created attachment 14295 [details]
testcase (unreduced)

Reducing.
Comment 2 Richard Biener 2007-10-04 12:28:25 UTC
Reduced testcase, fails with -O:

typedef struct {
    unsigned long attr;
    int chars[2];
} cchar_t;
typedef struct _win_st {
    cchar_t _bkgrnd;
} WINDOW;
void render_char(WINDOW *win, cchar_t ch)
{
    if ((ch).chars[0] == L' '
	&& (ch).chars[1] == L'\0')
	ch = win->_bkgrnd;
}


#1  0x0000000000945da0 in bitfield_overlaps_p (blen=0x2b7db0ca8b70, 
    bpos=0x2b7db0cc43c0, fld=0x13f66d0, data=0x7ffff9e5cfc0)
    at /space/rguenther/src/svn/pointer_plus/gcc/tree-sra.c:2901
2901        gcc_unreachable ();
(gdb) call debug_tree (fld->element)
 <integer_cst 0x2b7db0ca8810 type <integer_type 0x2b7db0cb7000 long unsigned int> constant invariant 1>
Comment 3 Alexandre Oliva 2007-10-05 17:45:44 UTC
Testing patch at http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00298.html
Comment 4 Alexandre Oliva 2007-10-06 11:48:02 UTC
Subject: Bug 33655

Author: aoliva
Date: Sat Oct  6 11:47:51 2007
New Revision: 129052

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129052
Log:
gcc/ChangeLog:
PR tree-optimization/33655
* tree-sra.c (bitfield_overlaps_p): Handle array and complex
elements.
gcc/testsuite/ChangeLog:
PR tree-optimization/33655
* gcc.dg/torture/pr33655.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr33655.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c

Comment 5 H.J. Lu 2007-10-07 14:33:34 UTC
(In reply to comment #4)
> Subject: Bug 33655
> 
> Author: aoliva
> Date: Sat Oct  6 11:47:51 2007
> New Revision: 129052
> 
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129052
> Log:
> gcc/ChangeLog:
> PR tree-optimization/33655
> * tree-sra.c (bitfield_overlaps_p): Handle array and complex
> elements.
> gcc/testsuite/ChangeLog:
> PR tree-optimization/33655
> * gcc.dg/torture/pr33655.c: New.
> 
> Added:
>     trunk/gcc/testsuite/gcc.dg/torture/pr33655.c
> Modified:
>     trunk/gcc/ChangeLog
>     trunk/gcc/testsuite/ChangeLog
>     trunk/gcc/tree-sra.c
> 

This patch doesn't work on Linux/ia64. I got

Executing on host: /export/build/gnu/gcc/build-ia64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-ia64-linux/gcc/ /net/gnu-13/export/gnu/src/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr33655.c   -O1   -fno-show-column -S  -o pr33655.s    (timeout = 300)
/net/gnu-13/export/gnu/src/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr33655.c: In function 'render_char':^M
/net/gnu-13/export/gnu/src/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr33655.c:14: internal compiler error: in size_binop, at fold-const.c:2036^M
Please submit a full bug report,^M
with preprocessed source if appropriate.^M
See <http://gcc.gnu.org/bugs.html> for instructions.^M
Comment 6 wilson@specifix.com 2007-10-08 22:16:35 UTC
Subject: Re:  [4.3 Regression] ICE in bitfield_overlaps_p,
 at tree-sra.c:2901

hjl at lucon dot org wrote:
> This patch doesn't work on Linux/ia64. I got

IA-64 is using a TImode bitsizetype because it defines 
MAX_FIXED_MODE_SIZE to enable TImode.  The x86_64 port does not, so it 
ends up with a DImode bitsizetype and hence does not have the same 
problem.  It looks like a few other 64-bit ports will fail the same way 
though, like powerpc64 and s390.

We can fix this with small patch to add another bitsizetype conversion 
call.  I'll attach a patch.
Comment 7 Jim Wilson 2007-10-08 22:19:31 UTC
Created attachment 14324 [details]
add another conversion to bitsizetype

Here is an patch to fix the IA-64 failure for this testcase.  This makes the testcase work (i.e. gcc doesn't ICE), but has not been otherwise tested as yet.
Comment 8 Alexandre Oliva 2007-10-09 04:55:38 UTC
Subject: Bug 33655

Author: aoliva
Date: Tue Oct  9 04:55:17 2007
New Revision: 129152

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129152
Log:
PR tree-optimization/33655
PR middle-end/22156
* tree-sra.c (bitfield_overlaps_p): When fld->element is INTEGER_CST,
convert it to bitsizetype before size_binop call.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-sra.c

Comment 9 Alexandre Oliva 2007-10-09 04:56:08 UTC
Fixed