Alignment Problem With Double On Sparc
Fri May 31 12:42:00 GMT 2002
Lately I encountered a problem with GCC (gcc-3.0.3) on alignment of double
(long long or UINT64) variables on Sparc (Solaris 8). The following is a
description of the problem.
In our code, there are double variables which might not be 8-byte aligned
(nor the structures that contain these variables). In the non-optimized
the load/store of these variables are translated into two ld/st
There is no problem.
However, if I turn on -O2 option, the GCC compiler tries to use ldd/std
(load/store of double) instructions for both the variables' assignments and
copy of structures containing double variables. Because ldd/std expects
8-byte aligned addresses, it generates BUS_ERROR at run-time.
I tried a few Sparc specific GCC options, such as
>From the manual, these two options seem the exact choices for GCC
NOT to assume alignment and NOT to use ldd/std, but they didn't work
Have anyone encounter this problem before? Is there a solution to this?
Basically, I'm looking for a way to still do -O2 optimization, but not to
use ldd/std (i.e. for GCC not to assume 8-byte alignment on double
variables and structures that contain them).
Any help is appreciated. Thanks.
More information about the Gcc-help