This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bad and/or stupid code for DImode compares with gcc 4.6.1

> 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.  

> For
> 	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
> like
> 	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
> .L4:
>           ret

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)?

Eric Botcazou

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]