AVR byte swap optimization
Uros Bizjak
ubizjak@gmail.com
Mon Nov 27 12:30:00 GMT 2006
Denis Vlasenko wrote:
>> The following macro expands to some rather frightful code on the AVR:
>>
>> #define BSWAP_16(x) \
>> ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
>
> Sometimes gcc is generating better code if you cast
> values instead of masking. Try:
>
> ( (uint8_t)((x) >> 8) | ((uint8_t)(x)) << 8 )
gcc > 3.4.x always generates better code for casted values. This is PR
middle-end/29749, and it affects i386 linux too.
Uros.
More information about the Gcc
mailing list