[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2024-03-22 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||law at gcc dot gnu.org

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2024-01-27 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- 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 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
leal4(%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.

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-12-10 Thread zfigura at codeweavers dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #13 from Zeb Figura  ---
(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?

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-12-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #12 from Andrew Pinski  ---
(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 ...

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-12-10 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #11 from Sam James  ---
(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.

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-12-10 Thread hanno--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

Jens-Hanno Schwalm  changed:

   What|Removed |Added

 CC||ha...@schwalm-bremen.de

--- Comment #10 from Jens-Hanno Schwalm  ---
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.

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-06-26 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #9 from Sam James  ---
Yes - primarily from znver4 users who build with -march=native (or
-march=znver4).

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-06-26 Thread amonakov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #8 from Alexander Monakov  ---
(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?

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-06-26 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #7 from Sam James  ---
We keep getting quite a few reports of this downstream.

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-06-23 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |12.4

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-06-16 Thread amonakov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #6 from Alexander Monakov  ---
Huh? Just compile the supplied testcases without avx512, you'll see proper
stack realignment.

[Bug target/110273] [12/13/14 Regression] i686-w64-mingw32 with -mavx512f generates AVX instructions without stack alignment

2023-06-16 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273

--- Comment #5 from H.J. Lu  ---
GCC doesn't align stack for Windows.  As a workaround, one can pass
-muse-unaligned-vector-move to newer assembler.