On 9/10/2010 2:17 AM, Dave Martin wrote:

> (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. 

True, but undefined-ness (or, in this case, implementation-defined-ness,
IIRC) helps the compiler; it's free to do as it wants.  So, this is no
excuse for the compiler generating slow code.  (In particular, the
compiler needn't generate a test to see whether the argument is greater
than INT_MAX.)

-- 
Mark Mitchell
CodeSourcery
m...@codesourcery.com
(650) 331-3385 x713

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

Reply via email to