This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: AVR byte swap optimization
- From: Denis Vlasenko <vda dot linux at googlemail dot com>
- To: gcc at gcc dot gnu dot org, "Shaun Jackman" <sjackman at gmail dot com>
- Cc: avr-gcc-list at nongnu dot org
- Date: Mon, 27 Nov 2006 02:19:56 +0100
- Subject: Re: AVR byte swap optimization
- References: <7f45d9390611171530g4c12f68dua3ade87a8b4147b0@mail.gmail.com>
On Saturday 18 November 2006 00:30, Shaun Jackman 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 )
--
vda