This is the mail archive of the
mailing list for the GCC project.
Re: Bad and/or stupid code for DImode compares with gcc 4.6.1
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: apl at alum dot mit dot edu
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 31 Oct 2012 19:38:17 +0100
- Subject: Re: Bad and/or stupid code for DImode compares with gcc 4.6.1
- References: <D90579E7-208A-44E3-A876-20C4BA620D0B@me.com>
> I see one case that seems really stupid, and one that's just wrong. I'm
> thinking that either I have something really flawed with my port's handing
> of DImode or that there was a bug in 4.6.1. The port is only failing
> about 2100 dejagnu tests (passing 64000+) and a good chunk of the failures
> are due to the ridiculously small data-memory size of the chip.
Please do not use "bad code", it's ambiguous, always use "wrong code" instead.
> long long int x;
> if ( x < 0 ) return 0 else return 2;
> I see code that compares MSBs and branches on < (less than) as expected.
> But then it goes and checks the MSBs for != , and finally it checks the
> LSBS and emits a conditional branch to the ELSE, followed by an
> unconditional branch to the ELSE, so that I end up with code that looks
> mov $r1,x
> mov $r2,x+4
> cmpi $r2,0
> jlt .L5
> cmpi $r2,0 <=== totally redundant for "x < 0" comparisons
> jne .L2
> cmpi $r1,0
> jmp .L4
> .L5 : movi $r1, 0
> jump .L4
> .L2 : movi $r1, 2
While poor code is expected at -O0, wrong code isn't of course. Could you
post a compilable testcase instead of an excerpt and the contents of the
.expand dump file (compile with -fdump-rtl-expand to get it)?