On Fri, Aug 03, 2007 at 06:24:06PM +0100, Paul Brook wrote: > On Friday 03 August 2007, Jonathan S. Shapiro wrote: > > Then it seems very curious that the constant folding should fail on this > > platform. Any idea what may be going on here? > > You're exploiting a hole in the C aliasing rules by accessing a 32-bit int as > type char. I tested several compilers (4.2, 4.1 and 3.4 x86, 4.2 m68k and 4.2 > arm) and the only one that eliminated the comparison was 3.4-x86.
FWIW, rewriting it with the "obvious" union approach seems to give the desired results on 4.2 arm with and without -mbig-endian. -Nathan