https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87421
Bug ID: 87421 Summary: GCC generates unaligned movdqa Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: yshuiv7 at gmail dot com Target Milestone: --- C++ Test case: struct A { unsigned int a1; long a5; unsigned int a6; }; int fun(A *res); int fun2(A *desc) { A resource; fun(&resource); *desc = resource; return 0; } Target: amd64 Compiler flags: g++ test.cc -c -O2 -fno-omit-frame-pointer -std=gnu++11 Compiles to: 0000000000000000 <_Z4fun2P1A>: // Assuming 16 bytes stack alignment 0: 55 push %rbp // rsp now aligns to 16 bytes + 8 bytes 1: 48 89 e5 mov %rsp,%rbp // rbp also aligns to 16 + 8 4: 53 push %rbx 5: 48 89 fb mov %rdi,%rbx 8: 48 8d 7d d0 lea -0x30(%rbp),%rdi c: 48 83 ec 28 sub $0x28,%rsp 10: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 17: 00 00 19: 48 89 45 e8 mov %rax,-0x18(%rbp) 1d: 31 c0 xor %eax,%eax 1f: e8 00 00 00 00 callq 24 <_Z4fun2P1A+0x24> 24: 48 8b 45 e0 mov -0x20(%rbp),%rax 28: 66 0f 6f 45 d0 movdqa -0x30(%rbp),%xmm0 // rbp-0x30 is not aligned to 16 bytes 2d: 48 89 43 10 mov %rax,0x10(%rbx) 31: 0f 11 03 movups %xmm0,(%rbx) 34: 48 8b 55 e8 mov -0x18(%rbp),%rdx 38: 64 48 33 14 25 28 00 xor %fs:0x28,%rdx 3f: 00 00 41: 75 09 jne 4c <_Z4fun2P1A+0x4c> 43: 48 83 c4 28 add $0x28,%rsp 47: 31 c0 xor %eax,%eax 49: 5b pop %rbx 4a: 5d pop %rbp 4b: c3 retq 4c: e8 00 00 00 00 callq 51 <_Z4fun2P1A+0x51>