[Bug c/50444] unaligned movdqa instruction after inlining
john.salmon at deshaw dot com
gcc-bugzilla@gcc.gnu.org
Sun Sep 25 15:45:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50444
--- Comment #1 from John Salmon <john.salmon at deshaw dot com> 2011-09-25 15:22:07 UTC ---
Here's a slightly smaller test case. The problem is the 'movdqa'. According
the x86-64 ABI, rsp+8 is 16-bit aligned at the entry to main, and therefore so
is %rdi when we try to execute
movdqa %xmm0, (%rdi)
resulting in segv.
thsalmonj@drdlogin0039.en.desres$ cat e2.c
#include <stdint.h>
#include <emmintrin.h>
#include <string.h>
struct a4x32{
uint32_t v[4];
};
struct a1xm128i{
__m128i m;
};
static struct a4x32 zero () {
struct a1xm128i c1x128;
struct a4x32 c4x32;
c1x128.m = _mm_setzero_si128();
memcpy (&c4x32.v[0], &c1x128.m, sizeof (c4x32));
return c4x32;
}
struct S {
struct a4x32 v;
};
void method (struct S * e) {
e->v = zero ();
}
int main (int argc, char **argv) {
struct S e;
method(&e);
return e.v.v[0];
}
salmonj@drdlogin0039.en.desres$ desres-cleanenv -m gcc/4.6.1-23A/bin gcc -Wall
-O -std=c99 -pedantic -S e2.c
salmonj@drdlogin0039.en.desres$ desres-cleanenv -m gcc/4.6.1-23A/bin gcc e2.s
salmonj@drdlogin0039.en.desres$ ./a.out
Segmentation fault (core dumped)
salmonj@drdlogin0039.en.desres$ cat e2.s
.file "e2.c"
.text
.globl method
.type method, @function
method:
.LFB522:
.cfi_startproc
pxor %xmm0, %xmm0
movdqa %xmm0, (%rdi)
ret
.cfi_endproc
.LFE522:
.size method, .-method
.globl main
.type main, @function
main:
.LFB523:
.cfi_startproc
subq $16, %rsp
.cfi_def_cfa_offset 24
movq %rsp, %rdi
call method
movl (%rsp), %eax
addq $16, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE523:
.size main, .-main
.ident "GCC: (GNU) 4.6.1"
.section .note.GNU-stack,"",@progbits
salmonj@drdlogin0039.en.desres$
More information about the Gcc-bugs
mailing list