On Fri, Sep 10, 2010 at 2:14 AM, Nicolas Pitre <nicolas.pi...@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

_______________________________________________
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-toolchain

Reply via email to