* [Bug target/110273] i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
@ 2023-06-15 21:54 ` zfigura at codeweavers dot com
2023-06-15 22:25 ` pinskia at gcc dot gnu.org
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: zfigura at codeweavers dot com @ 2023-06-15 21:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #1 from Zebediah Figura <zfigura at codeweavers dot com> ---
Created attachment 55335
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55335&action=edit
gcc -v output, from godbolt
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
2023-06-15 21:54 ` [Bug target/110273] " zfigura at codeweavers dot com
@ 2023-06-15 22:25 ` pinskia at gcc dot gnu.org
2023-06-16 8:00 ` amonakov at gcc dot gnu.org
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-15 22:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The difference is the inlining of memcpy if I used -minline-all-stringops, the
realignment comes back.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
2023-06-15 21:54 ` [Bug target/110273] " zfigura at codeweavers dot com
2023-06-15 22:25 ` pinskia at gcc dot gnu.org
@ 2023-06-16 8:00 ` amonakov at gcc dot gnu.org
2023-06-16 8:40 ` amonakov at gcc dot gnu.org
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-06-16 8:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Seems to work fine with explicit '-mincoming-stack-boundary=2' on the command
line, even though it should make no difference for the 32-bit MinGW target.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (2 preceding siblings ...)
2023-06-16 8:00 ` amonakov at gcc dot gnu.org
@ 2023-06-16 8:40 ` amonakov at gcc dot gnu.org
2023-06-16 16:50 ` [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f " hjl.tools at gmail dot com
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-06-16 8:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #4 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Further reduced:
void f()
{
int c[4] = { 0, 0, 0, 0 };
int cc[8] = { 0 };
asm("" :: "m"(c), "m"(cc));
}
Also reproducible with -march=skylake-avx512 or even plain -mavx512f,
retitling.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (3 preceding siblings ...)
2023-06-16 8:40 ` amonakov at gcc dot gnu.org
@ 2023-06-16 16:50 ` hjl.tools at gmail dot com
2023-06-16 17:24 ` amonakov at gcc dot gnu.org
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: hjl.tools at gmail dot com @ 2023-06-16 16:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
GCC doesn't align stack for Windows. As a workaround, one can pass
-muse-unaligned-vector-move to newer assembler.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (4 preceding siblings ...)
2023-06-16 16:50 ` [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f " hjl.tools at gmail dot com
@ 2023-06-16 17:24 ` amonakov at gcc dot gnu.org
2023-06-23 9:42 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-06-16 17:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #6 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Huh? Just compile the supplied testcases without avx512, you'll see proper
stack realignment.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (5 preceding siblings ...)
2023-06-16 17:24 ` amonakov at gcc dot gnu.org
@ 2023-06-23 9:42 ` rguenth at gcc dot gnu.org
2023-06-26 8:23 ` sjames at gcc dot gnu.org
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-23 9:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (6 preceding siblings ...)
2023-06-23 9:42 ` rguenth at gcc dot gnu.org
@ 2023-06-26 8:23 ` sjames at gcc dot gnu.org
2023-06-26 8:26 ` amonakov at gcc dot gnu.org
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-06-26 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
We keep getting quite a few reports of this downstream.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (7 preceding siblings ...)
2023-06-26 8:23 ` sjames at gcc dot gnu.org
@ 2023-06-26 8:26 ` amonakov at gcc dot gnu.org
2023-06-26 8:32 ` sjames at gcc dot gnu.org
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-06-26 8:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #8 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to Sam James from comment #7)
> We keep getting quite a few reports of this downstream.
Of this mingw32 stack realignment issue specifically, i.e. Wine breakage when
AVX512 is enabled via CFLAGS?
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (8 preceding siblings ...)
2023-06-26 8:26 ` amonakov at gcc dot gnu.org
@ 2023-06-26 8:32 ` sjames at gcc dot gnu.org
2023-12-10 17:58 ` hanno@schwalm-bremen.de
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-06-26 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #9 from Sam James <sjames at gcc dot gnu.org> ---
Yes - primarily from znver4 users who build with -march=native (or
-march=znver4).
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (9 preceding siblings ...)
2023-06-26 8:32 ` sjames at gcc dot gnu.org
@ 2023-12-10 17:58 ` hanno@schwalm-bremen.de
2023-12-10 19:59 ` sjames at gcc dot gnu.org
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: hanno@schwalm-bremen.de @ 2023-12-10 17:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
Jens-Hanno Schwalm <hanno@schwalm-bremen.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hanno@schwalm-bremen.de
--- Comment #10 from Jens-Hanno Schwalm <hanno@schwalm-bremen.de> ---
Hi, i think we found a very-similar issue in darktable code, you might look at
https://github.com/darktable-org/darktable/pull/15742
In short
- reported with gcc 13.2.1, -march=znver4 or using -fvect-cost-model=dynamic
The code in question was
```
typedef struct dt_draw_curve_t
{
CurveData c;
CurveSample csample;
} dt_draw_curve_t;
static inline void dt_draw_curve_set_point(dt_draw_curve_t *c,
const int num,
const float x,
const float y)
{
c->c.m_anchors[num].x = x;
c->c.m_anchors[num].y = y;
}
static void _generate_curve_lut( ...)
{
...
dt_iop_rgbcurve_node_t curve_nodes[3][20];
...
for(int k = 0; k < d->params.curve_num_nodes[ch]; k++)
dt_draw_curve_set_point(d->curve[ch], k,
curve_nodes[ch][k].x,
curve_nodes[ch][k].y);
...
}
```
The relevant point here was:
even if the curve_nodes are not aligned64 the compiled code looked like
lea (%rcx, %rbx,1), %rdi
vmoaps -0x220(%rbp, %rdi,8), %ymm2
vmoups %ymm2, 0x18(%r15,%rcx,8)
forcing an alignment64 on curve_nodes fixed the problem
reporting this as one of darktable devs - no compiler expert at all - and never
reported here before. Yet this seems a bug and possibly the same are originally
reported here.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (10 preceding siblings ...)
2023-12-10 17:58 ` hanno@schwalm-bremen.de
@ 2023-12-10 19:59 ` sjames at gcc dot gnu.org
2023-12-10 20:02 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-12-10 19:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #11 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Jens-Hanno Schwalm from comment #10)
> Hi, i think we found a very-similar issue in darktable code, you might look
> at
>
> https://github.com/darktable-org/darktable/pull/15742
>
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, although I
suspect it isn't here.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (11 preceding siblings ...)
2023-12-10 19:59 ` sjames at gcc dot gnu.org
@ 2023-12-10 20:02 ` pinskia at gcc dot gnu.org
2023-12-10 23:28 ` zfigura at codeweavers dot com
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-10 20:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(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 might look
> > at
> >
> > https://github.com/darktable-org/darktable/pull/15742
> >
>
> 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, although I
> suspect it isn't here.
Though it might be PR 110027 ...
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (12 preceding siblings ...)
2023-12-10 20:02 ` pinskia at gcc dot gnu.org
@ 2023-12-10 23:28 ` zfigura at codeweavers dot com
2024-01-27 19:01 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: zfigura at codeweavers dot com @ 2023-12-10 23:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #13 from Zeb Figura <zfigura at codeweavers dot com> ---
(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 might look
> > at
> >
> > https://github.com/darktable-org/darktable/pull/15742
> >
>
> 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, although I
> suspect it isn't here.
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 will
just use vmovdqu and not bother aligning the stack. No idea what the more
targeted optimization is.]
I'd assume this is a bug with -mstackrealign, but I also don't understand what
the intended purpose of -mstackrealign is. How does it differ from
-mincoming-stack-boundary=2 or -mpreferred-stack-boundary=2?
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (13 preceding siblings ...)
2023-12-10 23:28 ` zfigura at codeweavers dot com
@ 2024-01-27 19:01 ` hjl.tools at gmail dot com
2024-03-22 13:45 ` law at gcc dot gnu.org
2024-06-20 9:13 ` [Bug target/110273] [12/13/14/15 " rguenth at gcc dot gnu.org
16 siblings, 0 replies; 18+ messages in thread
From: hjl.tools at gmail dot com @ 2024-01-27 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
--- Comment #14 from H.J. Lu <hjl.tools at gmail dot com> ---
(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 might look
> > > at
> > >
> > > https://github.com/darktable-org/darktable/pull/15742
> > >
> >
> > 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, although I
> > suspect it isn't here.
>
> 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 will
> just use vmovdqu and not bother aligning the stack. No idea what the more
> targeted optimization is.]
>
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]$
It works for me. Please file a separate bug if-mstackrealign -mavx512f -O2
doesn't work for you on Linux.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (14 preceding siblings ...)
2024-01-27 19:01 ` hjl.tools at gmail dot com
@ 2024-03-22 13:45 ` law at gcc dot gnu.org
2024-06-20 9:13 ` [Bug target/110273] [12/13/14/15 " rguenth at gcc dot gnu.org
16 siblings, 0 replies; 18+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-22 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |law at gcc dot gnu.org
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug target/110273] [12/13/14/15 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment
2023-06-15 21:53 [Bug target/110273] New: i686-w64-mingw32 with -march=znver4 generates AVX instructions without stack alignment zfigura at codeweavers dot com
` (15 preceding siblings ...)
2024-03-22 13:45 ` law at gcc dot gnu.org
@ 2024-06-20 9:13 ` rguenth at gcc dot gnu.org
16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-20 9:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.4 |12.5
--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.4 is being released, retargeting bugs to GCC 12.5.
^ permalink raw reply [flat|nested] 18+ messages in thread