From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0CDA3858C2D; Sat, 27 Jan 2024 19:01:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0CDA3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706382072; bh=xg81suwxXDxgaAo1GFUxUmiQ8OZyVDD3AtQslQDP+JU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p4Rh6c+bAQH2sHTJq1tM0sdNSpjKIjn+2WKYp7YXFDCho1oiDVRxHF0trSXcbAoKq O3qk8Kye74mTlkahpXMf+OcEsdM3imQsji+6NEQb2AE2Fx7/Uk9DQbke7dBrA6MHVB kvs7ma5skVpY8CAVDKV+kvgQSg5CWNh/ms2ESPjE= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment Date: Sat, 27 Jan 2024 19:01:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110273 --- Comment #14 from H.J. Lu --- (In reply to Zeb Figura from comment #13) > (In reply to Sam James from comment #11) > > (In reply to Jens-Hanno Schwalm from comment #10) > > > Hi, i think we found a very-similar issue in darktable code, you migh= t look > > > at > > >=20 > > > https://github.com/darktable-org/darktable/pull/15742 > > >=20 > >=20 > > If you're hitting this on another target than i686-w64-mingw32, please = file > > a new bug. We can always mark it as a dupe if it turns out to be, altho= ugh I > > suspect it isn't here. >=20 > FWIW, I think the relevant part of i686-w64-ming32 is actually just > STACK_REALIGN_DEFAULT. I can reproduce the same lack of alignment with > "-mstackrealign -mavx512 -O2" with i386-linux-gnu, whereas "-mstackrealign > -mavx2 -O2" does align the stack. [-O2 is necessary here otherwise gcc wi= ll > just use vmovdqu and not bother aligning the stack. No idea what the more > targeted optimization is.] >=20 For the attached testcase here, GCC 13.2 generates: [hjl@gnu-cfl-3 tmp]$ gcc -S -mstackrealign -mavx512f -O2 -m32 x.c [hjl@gnu-cfl-3 tmp]$ head -20 x.s .file "x.c" .text .p2align 4 .globl ddraw7_GetCaps .type ddraw7_GetCaps, @function ddraw7_GetCaps: .LFB0: .cfi_startproc leal 4(%esp), %ecx .cfi_def_cfa 1, 0 andl $-16, %esp <<<<< Stack realignment. vpxor %xmm0, %xmm0, %xmm0 xorl %eax, %eax pushl -4(%ecx) pushl %ebp movl %esp, %ebp .cfi_escape 0x10,0x5,0x2,0x75,0 pushl %edi pushl %ecx .cfi_escape 0xf,0x3,0x75,0x78,0x6 [hjl@gnu-cfl-3 tmp]$=20 It works for me. Please file a separate bug if-mstackrealign -mavx512f -O2 doesn't work for you on Linux.=