AVR byte swap optimization

Paul Brook paul@codesourcery.com
Sat Nov 18 17:54:00 GMT 2006


> Ideally, this macro would expand to three mov instructions and a ret.
> Is there anything I can do to help GCC along here? I'm using GCC 4.1.0
> with -O2.
>
> I won't bother to show bswap_32 here, which produces a real disaster!
> Think 47 instructions, for what should be 6.

Use gcc head, __builtin_bswap and make sure the AVR backend implements the 
bswap rtl patterns.

Future versions of gcc may also be able to recognise these idioms without 
using the builtin, but AFAIK that's not been implemented yet.

Paul



More information about the Gcc mailing list