https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113989
Bug ID: 113989 Summary: MinGW generates unaligned vmovdqa64 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: xjkp2283572185 at gmail dot com Target Milestone: --- === Compiler === Using built-in specs. COLLECT_GCC=D:\Tools\gcc\bin\g++.exe COLLECT_LTO_WRAPPER=D:/Tools/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/14.0.1/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../configure --disable-werror --prefix=/home/luo/x86_64-w64-mingw32-native-gcc14 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --enable-multilib --enable-languages=c,c++ --disable-sjlj-exceptions --enable-threads=win32 Thread model: win32 Supported LTO compression algorithms: zlib gcc version 14.0.1 20240130 (experimental) (GCC) === Source Code === // a.cpp struct alignas(64) a { char buf[64]{}; }; a f(long long i) noexcept; int main() { f(1); return 0; } // b.bpp struct alignas(64) a { char buf[64]{}; }; a f(long long i) noexcept { using v[[gnu::vector_size(64)]] = long long; v vi{i,i,i,i,i,i,i,i}; a res{}; __builtin_memcpy(&res, &vi, 64); return res; } === Command === g++ a.cpp b.cpp -march=znver4 -Ofast -g === Result === Run it with gdb and it crashes: Thread 1 received signal SIGSEGV, Segmentation fault. 0x00007ff78ac01549 in f (i=i@entry=1) at b.cpp:10 10 __builtin_memcpy(&res, &vi, 64); (gdb) disassemble Dump of assembler code for function _Z1fx: 0x00007ff78ac01540 <+0>: vpbroadcastq %rdx,%zmm0 0x00007ff78ac01546 <+6>: mov %rcx,%rax => 0x00007ff78ac01549 <+9>: vmovdqa64 %zmm0,(%rcx) 0x00007ff78ac0154f <+15>: vzeroupper 0x00007ff78ac01552 <+18>: ret End of assembler dump. (gdb) info registers rcx rcx 0x5ffe90 6291088 (gdb) disassemble main Dump of assembler code for function main(): 0x00007ff640f62a50 <+0>: sub $0x68,%rsp 0x00007ff640f62a54 <+4>: call 0x7ff640f61610 <__main> 0x00007ff640f62a59 <+9>: lea 0x20(%rsp),%rcx 0x00007ff640f62a5e <+14>: mov $0x1,%edx 0x00007ff640f62a63 <+19>: call 0x7ff640f61540 <_Z1fx> 0x00007ff640f62a68 <+24>: xor %eax,%eax 0x00007ff640f62a6a <+26>: add $0x68,%rsp 0x00007ff640f62a6e <+30>: ret End of assembler dump. But if we compile the program with "g++ a.cpp b.cpp -march=znver4 -Ofast -fno-asynchronous-unwind-tables -fno-exceptions", the program won't crash.