[Bug target/89581] Unneeded stack alignment on windows x86

2020-12-16 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89581

Gabriel Ravier  changed:

   What|Removed |Added

 CC||gabravier at gmail dot com

--- Comment #2 from Gabriel Ravier  ---
I can reproduce this, the code generation seems to have gotten much worse,
here's what I get with -O3 -mavx2 :

f:
  vmovq QWORD PTR [rsp-40], xmm0
  vmovq QWORD PTR [rsp-32], xmm1
  vmovapd xmm5, XMMWORD PTR [rsp-40]
  vmovq QWORD PTR [rsp-24], xmm2
  vmovq QWORD PTR [rsp-16], xmm3
  vaddpd xmm4, xmm5, XMMWORD PTR [rsp-24]
  vmovapd XMMWORD PTR [rsp-40], xmm4
  vmovsd xmm1, QWORD PTR [rsp-32]
  vmovsd xmm0, QWORD PTR [rsp-40]
  ret

[Bug target/89581] Unneeded stack alignment on windows x86

2019-03-04 Thread yyc1992 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89581

--- Comment #1 from Yichao Yu  ---
The problem is still there when compiled with -O2

```
f:
pushq   %rbp
vmovq   (%r8), %xmm1
movq%rcx, %rax
vmovq   8(%r8), %xmm0
vaddsd  (%rdx), %xmm1, %xmm1
vaddsd  8(%rdx), %xmm0, %xmm0
movq%rsp, %rbp
andq$-16, %rsp
vmovsd  %xmm1, (%rcx)
vmovsd  %xmm0, 8(%rcx)
leave
ret
```


but is not there under `-O2` when the arguments and results are passed
explicitly by reference.

```
void f2(vdouble *res, const vdouble *x, const vdouble *y)
{
*res = (vdouble){x->x1 + y->x1, x->x2 + y->x2};
}
```


```
f2:
vmovsd  8(%rdx), %xmm0
vmovsd  (%rdx), %xmm1
vaddsd  8(%r8), %xmm0, %xmm0
vaddsd  (%r8), %xmm1, %xmm1
vmovsd  %xmm0, 8(%rcx)
vmovsd  %xmm1, (%rcx)
```

The problem comes back, however, with the explicit pass by reference version
when compiled under -O3

```
f2:
pushq   %rbp
vmovapd (%rdx), %xmm0
vaddpd  (%r8), %xmm0, %xmm0
movq%rsp, %rbp
andq$-16, %rsp
vmovaps %xmm0, (%rcx)
leave
ret
```