-munaligned-doubles and -mno-faster-structs do not work on Sparc with -O2
Zhang, Bo
bzhang@convergentnet.com
Tue Jun 4 07:50:00 GMT 2002
Hello, all,
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
brief 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
code, the load/store of these variables are translated into two ld/st
instructions. 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
-munaligned-doubles
-mno-faster-structs
>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
at all.
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.
Bo
More information about the Gcc-bugs
mailing list