This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
ARM constant folding bug?
- From: "Jonathan S. Shapiro" <shap at eros-os dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 03 Aug 2007 12:09:15 -0400
- Subject: ARM constant folding bug?
This is observed on gcc-3.4.6. It may be a known issue, and/or it may be
fixed in later compilers.
For bringup purposes, I wrote an inline assembly hack to get the cross
compiler to tell me whether the target is little/big endian. The code
fragment is:
const unsigned long ul = 0x04030201llu;
if ( *((char *) &ul) == 0x1 )
ASMDEF(LITTLE_ENDIAN);
else
ASMDEF(BIG_ENDIAN);
The expectation is that when run with -O2, the compiler should
constant-fold all of this stuff away, resulting in exactly one ASMDEF.
On i386 and m68k, the constant folding occurs as expected. For ARM it
does not(!).
I am not surprised that there is different behavior for different
targets, but I am very surprised that *this* behavior is different. This
optimization ought to be happening in the mid-end, and it ought to be
entirely machine independent.
Can somebody explain what is going on here?
shap