This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: ARM constant folding bug?
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Jonathan S. Shapiro'" <shap at eros-os dot com>, <gcc at gcc dot gnu dot org>
- Date: Fri, 3 Aug 2007 17:24:28 +0100
- Subject: RE: ARM constant folding bug?
- References: <1186157355.23564.84.camel@shap.om-md.eros-os.com>
On 03 August 2007 17:09, Jonathan S. Shapiro wrote:
> 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.
I'm a bit surprised too. But it occurs to me that the ARM, unlike the i386
and m68k, is bi-endian. Perhaps you can't actually know which mode it's
running in at compile time and /have/ to test it at runtime?
cheers,
DaveK
--
Can't think of a witty .sigline today....