gcc 3.2 - float-related errors with -O -march=athlon (PR 6845 and 7390)

Jakub Bogusz qboosh@pld.org.pl
Mon Sep 9 15:56:00 GMT 2002


Sorry for annoying, but I've figured some more facts that may be
helpful...

I don't but it in GNATS - it's already there, under #6845 and (similar
case) #7390. Also #7124 looks very similar.

On Fri, Sep 06, 2002 at 08:42:51PM +0200, Jakub Bogusz wrote:
> On Thu, Sep 05, 2002 at 11:54:07PM +0200, Jakub Bogusz wrote:
> > I get errors when trying to compile with -march=athlon and at least -O
> > (-O1, -O2, -O3).
> > Errors stop appearing after changing optimization to -O0, -Os or
> > -march=i686.
> > 
> > $ gcc -v
> > Reading specs from /usr/lib/gcc-lib/athlon-pld-linux/3.2/specs
> > Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,f77,gcov,java,objc,ksi,ada --enable-c99 --enable-long-long --enable-multilib --enable-nls --with-gnu-as --with-gnu-ld --with-system-zlib --with-slibdir=/lib --without-x athlon-pld-linux
> > Thread model: posix
> > gcc version 3.2
> > 
> > 
> > This testcase is taken from lbreakout2, but file is cut down to less
> > than 1kB (and it still triggers bug).
> > It isn't rare case - I got very similar errors when trying to compile
> > XFree86 4.2.1 with "-O2 -march=athlon" optimization.
> > I'm using lbreakout2 code as example because it's simpler.
> > 
> > Example command line is:
> > 
> > $ gcc -c misc-b.i -O -march=athlon
> 
> I've done more tests, maybe this would help.
> Errors occur with (shellglob-like notation):
> -O{2,3} -march=athlon{,-tbird,-4,-xp,-mp}
> -O{2,3} -march=pentium{2,3,4}
> -O{2,3} -march=pentiumpro -mmx
> -O{2,3} -march=k6{,-2,-3}
> 
> And -march=pentium-mmx does _not_ trigger bug.

Generally - ICE occurs for k6 and i686 optimizations when any of
mmx,3dnow,sse,sse2 is enabled. Doesn't occur for i586 or with
"-mno-mmx -mno-3dnow -mno-sse -mno-sse2" (or subset of -mno-* options
if the rest are not supported by chosen CPU).

> > Then errors appear:
> > 
> > misc-b.c: In function `circle_intersect':
> > misc-b.c:58: unable to find a register to spill in class `FLOAT_REGS'
> > misc-b.c:58: this is the insn:
> > (insn 23 21 24 (set (subreg:SF (reg/v:DI 29 rmm0 [65]) 0)
> >         (minus:SF (subreg:SF (reg/v:DI 61) 0)
> >             (subreg:SF (reg/v:DI 1 rdx [59]) 0))) 533 {*fop_sf_1_nosse} (insn_list 8 (insn_list 4 (nil)))
> >     (nil))
> > misc-b.c:58: confused by earlier errors, bailing out
> 
> And using "-O -march=athlon-xp -mfpmath=sse" changes error message to:
> 
> misc-b.c: In function `circle_intersect':
> misc-b.c:58: unable to find a register to spill in class `SSE_REGS'
> misc-b.c:58: this is the insn:
> (insn 23 21 24 (set (subreg:SF (reg/v:DI 29 rmm0 [65]) 0)
>         (minus:SF (subreg:SF (reg/v:DI 61) 0)
>             (subreg:SF (reg/v:DI 1 rdx [59]) 0))) 535 {*fop_sf_1_sse} (insn_list 8 (insn_list 4 (nil)))
>     (nil))
> misc-b.c:58: confused by earlier errors, bailing out

Simplified testcase (original is identical as in PR 6845):

> typedef struct {
>     float x, y;
> } Vector;
> float circle_intersect( Vector m, Vector pos)
> {
>     Vector delta = { pos.x - m.x, pos.y - m.y};
>     return delta.x+delta.y;
> }
> 
> The key seems to be that struct is initialized by "= { , }" construct,
> and then both fields are used in some calculations.
> 
> After changing to "Vector delta; delta.x=pos.x-m.x; delta.y=pos.y-m.y"
> errors doesn't occur.

Also, ICE stops occurring after chaning "float" to "double" in struct.


Similar problem that I also mentioned (XFree86 compilation) has been
already reported in PR 7390 (for gcc 3.1, but it's still true for 3.2),
and miPck1Prim.i file is attached there.
It's also related to struct consisting of floats, and ICE stops
occurring after changing float to double.
The difference is that ICE occurs only when compiling for i686 with mmx
or 3dnow, but _doesn't_ occur when sse is enabled (i.e. "-O -march=athlon"
generates ICE, "-O -march=athlon-xp" doesn't; with -march=athlon both
mmx and 3dnow must be disabled to avoid ICE).


-- 
Jakub Bogusz    http://prioris.mini.pw.edu.pl/~qboosh/
PLD Linux       http://www.pld.org.pl/



More information about the Gcc-bugs mailing list