avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] if-statement is optimized wrong


From: Jörgen
Subject: Re: [avr-libc-dev] if-statement is optimized wrong
Date: Mon, 5 May 2003 07:41:20 -0700 (PDT)

Tried it on my setup. Seems to always return 0.
Included are the list files from -o0 and -os.



Reading specs from
c:\WinAVR\bin\..\lib\gcc-lib\avr\3.3\specs
Configured with: ../configure
--prefix=/e/avrdev/install --target=avr --enable-l
anguages=c,c++ --disable-nls
Thread model: single
gcc version 3.3 20030310 (prerelease)


--- Michael Kristensen <address@hidden> wrote:
> Hi,
> 
> I'm having trouble compiling the code snippet below.
> If I use anything above 
> -O0 the if-statement it won't work.
> 
> Michael
> 
> $ avr-gcc -v
> Reading specs from
> /usr//bin/../lib/gcc-lib/avr/3.3/specs
> Configured with: ../configure --prefix=/usr
> --mandir=/usr/share/man 
> --infodir=/usr/share/info --enable-languages=c,c++
> --disable-nls --target=avr 
> i386-redhat-linux
> Thread model: single
> gcc version 3.3 20030428 (prerelease)
> 
> 
> 
> /*
> avr-gcc  -S -g -O2 -Wall -mmcu=atmega128  gcc-fail.c
> gcc optimizes badly above -O0 :
> it thinks that the if always go one way.
> */
> 
> #include <inttypes.h>
> #include <avr/io.h>
> 
> uint8_t example(void) {
>  static uint8_t prev_input;
>  uint8_t input, dinput, ret;
> 
>  input = PINE;
>  dinput = prev_input ^ input;
>  prev_input = input;
> 
>  if (dinput & 0x01)
>    ret = 1;
>  else
>    ret = 0;
> 
>  return ret;
> }
> 
> 
> _______________________________________________
> AVR-libc-dev mailing list
> address@hidden
> http://mail.nongnu.org/mailman/listinfo/avr-libc-dev



__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com




reply via email to

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