[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Double 'andi' missed optimization
From: |
eric |
Subject: |
Re: [avr-gcc-list] Double 'andi' missed optimization |
Date: |
Thu, 19 Jun 2003 21:47:33 GMT |
>
> I've found what looks like a missed optimization in avr-
gcc 3.3 20030512
>
> uint8_t Encoder;
>
> Encoder = (PORTD >> 4) & 12;
> 0: 82 b3 in r24, 0x12 ; 18
> 2: 82 95 swap r24
> 4: 8f 70 andi r24, 0x0F ; 15
> 6: 8c 70 andi r24, 0x0C ; 12
>
> The 4 bit shift is implemented as a swap/andi , but with
an explicit andi
> afterwards, it seems like an obvious optimization to
combine them.
>
> Trivial example code below, compiled with:
> avr-gcc -c e.c -g -O2 -mmcu=at90s8535 -o e.o
>
>
> #include <avr/io.h>
> #include <inttypes.h>
>
>
> int8_t test ()
> {
>
> uint8_t Encoder;
>
> Encoder = (PORTD >> 4) & 12;
> return(Encoder);
>
> }
>
>
Please fill out a GCC bug report here:
<http://gcc.gnu.org/bugzilla/>
Thanks
Eric