[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Optimization bug in AVRGCC 3.3 compiler

From: Marek Michalkiewicz
Subject: Re: [avr-gcc-list] Optimization bug in AVRGCC 3.3 compiler
Date: Sun, 6 Apr 2003 18:51:52 +0200
User-agent: Mutt/1.4i

On Sun, Apr 06, 2003 at 08:35:26PM +0400, Alexei Semenov wrote:
> I suppose the wrong compiling is effect of porting avr-gcc to win32.

Not necessarily, could also be a real bug which has already been fixed
in CVS between 20030312 and 20030405.

> int main(void) {
>    unsigned char v= 0;
>    for(;;)
>       if ((PIND ^ v) & 1) // do wrong compiling
>          v= ~v;
> }
> produces next erroneous assembler code:
>         ...
> .L6:
>         in r24,48-0x20
>         rjmp .L6
>         ...

The value assigned to "v" is not used for anything (like PORTB write in
your first example), so in this case GCC is correct to optimize it away.

> int main(void) {
>    signed char v= 0;    // signed instead of unsigned
>    for(;;)
>       if ((PIND ^ v) & 1) // do correct compiling
>          v= ~v;
> }
> produces next correct but redundant assembler code:

You're right here - but if the code is correct (just not as efficient
as it should be), I'll look into fixing it after 3.3 is released
(which is "real soon now" since December 2002...) and after getting
CVS head (3.4) to build again (currently fails due to a change in


reply via email to

[Prev in Thread] Current Thread [Next in Thread]