This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Align problem of g77
- To: gcc-help at gcc dot gnu dot org
- Subject: Align problem of g77
- From: thhsieh at linux dot org dot tw
- Date: Sat, 10 Nov 2001 18:06:43 +0800
Hello,
I am using the g77 compiler from the GCC-2.95.4 (pre-release snapshot).
We want to link our fortran code to the special library which could use
the Pentium 4 SSE2 instructions. Because the SSE2 instructions operate
on the %xmm registers which have 128 bits (16 bytes) long, which means
that if we want to move the data from the memory to the %xmm registers,
the data in the memory should be at least 128 bits aligned. Otherwise the
resulting program will just segment fault and cannot work at all.
I have dumpped the resulting assembly code compiled by g77. I saw that
if I invoke g77 with -malign-double, all the data structer in "COMMON"
block is aligned to 8 bytes or 32 bytes, depends on the size of the
arrays, e.g.,
Fortran:
integer xdim, tdim, vdim, ldim, n_mq
parameter (xdim=16, tdim=32, n_mq=11)
parameter (vdim=xdim**3, ldim=vdim*tdim)
double complex vb(ldim*12), vx(ldim*12*n_mq)
double complex vecs(ldim*6*(4+n_mq*2))
common /a1/ vb
common /a2/ vx
common /a3/ vecs
assembly:
.size pos_x_eox__,.Lfe2-pos_x_eox__
.comm a1_,25165824,32
.comm a2_,276824064,8
.comm a3_,327155712,8
For our purpose, the alignment of 32 bytes is OK for the SSE2 operation.
But the alignment of 8 bytes is not. So here is my question: Is there a
safe way to ensure that all the "COMMON" block data is aligned to the
32 bytes boundary? If there is no way to do this, could you tell me the
rule of g77 that how it determine the data to be aligned to 8-bytes
boundary or 32-byte boundary? I think with this rule I can adjust my
arrays to fit the requirement.
Thanks very much for your help in advance. :-)))
T.H.Hsieh
ps. Since I am not in this mailing list, so please CC your reply to
my mailbox. Thanks very much for your kindly help. :-)))