[PATCH] Optimize subregs of zero and sign extensions (take 2)

Roger Sayle roger@eyesopen.com
Thu Jan 22 22:33:00 GMT 2004


On Thu, 22 Jan 2004, John David Anglin wrote:
> Hi Roger,
> On Wed, Jan 21, 2004 at 07:10:11PM -0700, Roger Sayle wrote:
> >       * rtlanal.c (subreg_lsb_1): New function split out from subreg_lsb.
> >       (subreg_lsb): Change to call new subreg_lsb_1 helper function.
> >       * rtl.h (subreg_lsb_1): Prototype here.
> >       * simplify-rtx.c (simplify_subreg): Optimize subregs of zero and
> >       sign extensions.
>
> I haven't checked for sure but I think this patch is likely the cause
> of the following ICE on hppa64-hp-hpux11.11:
>
> ./xgcc -B./ -B/opt/gnu64/hppa64-hp-hpux11.11/bin/ -isystem /opt/gnu64/hppa64-hp-hpux11.11/include -isystem /opt/gnu64/hppa64-hp-hpux11.11/sys-include -L/xxx/gnu/gcc-3.3/objdir/gcc/../ld -O2  -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -Dpa64=1 -DELF=1 -mlong-calls -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I -I../../gcc/gcc -I../../gcc/gcc/ -I../../gcc/gcc/../include   -DL_divdi3 -c ../../gcc/gcc/libgcc2.c -fexceptions -fnon-call-exceptions -o libgcc/./_divdi3.o
> ../../gcc/gcc/libgcc2.c: In function `__divdi3':
> ../../gcc/gcc/libgcc2.c:1019: internal compiler error: in simplify_gen_subreg, at simplify-rtx.c:3442
>
> We have in frame 1:
> #1  0x400000000056630c in simplify_gen_subreg (outermode=HImode,
>     op=0x800003fffeb22240, innermode=SImode, byte=6)
>     at ../../gcc/gcc/simplify-rtx.c:3442
> 3442        abort ();


Doh!  Yes, this is indeed a problem with my patch.  It looks like we've
just simplified (subreg:HI (zero_extend:DI (reg:SI 373)) 6), where the
offset 6 is the lowpart of the DI.  We correctly simplify/optimize that
to a (subreg:HI (reg:SI 373) ?) except that we don't update the subreg
byte offset for the shorter mode.  The ? should be 2, not 6.

This works fine on an x86 endian machine, lowpart is zero, but I failed
to test on an opposite endian architecture.  The fix is to instead use
subreg_lowpart_offset to correct for the contracted mode.  I'm currently
bootstrapping and regression testing a patch.

Sorry for any inconvenience.

Roger
--



More information about the Gcc-patches mailing list