Thumb2 code size improvements
Dave Martin
dave.martin at linaro.org
Fri Sep 10 10:17:08 BST 2010
On Fri, Sep 10, 2010 at 2:14 AM, Nicolas Pitre <nicolas.pitre at linaro.org> wrote:
[...]
> lsl r0, r0, #28
> asr r0, r0, #28
> bx lr
>
> But I doubt gcc could ever become that smart.
Some pointed out to me that the tempting C equivalent
(int)((unsigned)c << 28) >> 28
is invalid C, because the result of the unsigned->signed cast (needed
to get arithmetic right shift) is undefined if the argument is >
INT_MAX. Maybe that's why the eembc code is so verbose.
Of course, that C snippet is often used in practice, and works on
common architectures using a sane integer representation.
Cheers
---Dave
More information about the linaro-toolchain
mailing list