public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113989] New: MinGW generates unaligned vmovdqa64
@ 2024-02-19 12:07 xjkp2283572185 at gmail dot com
2024-02-19 14:14 ` [Bug target/113989] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: xjkp2283572185 at gmail dot com @ 2024-02-19 12:07 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/113989] MinGW generates unaligned vmovdqa64
2024-02-19 12:07 [Bug target/113989] New: MinGW generates unaligned vmovdqa64 xjkp2283572185 at gmail dot com
@ 2024-02-19 14:14 ` rguenth at gcc dot gnu.org
2024-02-19 14:26 ` xjkp2283572185 at gmail dot com
2024-02-19 17:00 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-19 14:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113989
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Feels like the old issue that the incoming stack in main() is not aligned as
GCC it thinks it is? On x86_64-linux we dynamically re-align the stack:
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movl $1, %esi
movq %rsp, %rbp
.cfi_def_cfa_register 6
andq $-64, %rsp
subq $64, %rsp
movq %rsp, %rdi
call _Z1fx
does -mstackrealign make it work? I think there's some duplicate bugreports
about mingw and stack alignment.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/113989] MinGW generates unaligned vmovdqa64
2024-02-19 12:07 [Bug target/113989] New: MinGW generates unaligned vmovdqa64 xjkp2283572185 at gmail dot com
2024-02-19 14:14 ` [Bug target/113989] " rguenth at gcc dot gnu.org
@ 2024-02-19 14:26 ` xjkp2283572185 at gmail dot com
2024-02-19 17:00 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: xjkp2283572185 at gmail dot com @ 2024-02-19 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113989
--- Comment #2 from 严 逍宇 <xjkp2283572185 at gmail dot com> ---
(In reply to Richard Biener from comment #1)
> does -mstackrealign make it work?
It doesn't work. GDB shows that the address in rcx is still unaligned.
(gdb) disassemble
Dump of assembler code for function _Z1fx:
0x00007ff6659a1540 <+0>: vpbroadcastq %rdx,%zmm0
0x00007ff6659a1546 <+6>: mov %rcx,%rax
=> 0x00007ff6659a1549 <+9>: vmovdqa64 %zmm0,(%rcx)
0x00007ff6659a154f <+15>: vzeroupper
0x00007ff6659a1552 <+18>: ret
End of assembler dump.
(gdb) info registers rcx
rcx 0x5ffe90 6291088
Is there any way to temporarily block the bug?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/113989] MinGW generates unaligned vmovdqa64
2024-02-19 12:07 [Bug target/113989] New: MinGW generates unaligned vmovdqa64 xjkp2283572185 at gmail dot com
2024-02-19 14:14 ` [Bug target/113989] " rguenth at gcc dot gnu.org
2024-02-19 14:26 ` xjkp2283572185 at gmail dot com
@ 2024-02-19 17:00 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-19 17:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113989
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.
*** This bug has been marked as a duplicate of bug 49001 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-19 17:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 12:07 [Bug target/113989] New: MinGW generates unaligned vmovdqa64 xjkp2283572185 at gmail dot com
2024-02-19 14:14 ` [Bug target/113989] " rguenth at gcc dot gnu.org
2024-02-19 14:26 ` xjkp2283572185 at gmail dot com
2024-02-19 17:00 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).