https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89581

            Bug ID: 89581
           Summary: Unneeded stack alignment on windows x86
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yyc1992 at gmail dot com
  Target Milestone: ---

On windows, when compiling the following code with ` gcc -mavx2 a.c -o - -S -O3
-g0 -fno-asynchronous-unwind-tables -fomit-frame-pointer -Wall -Wextra`

```
typedef struct {
    double x1;
    double x2;
} vdouble __attribute__((aligned(16)));

vdouble f(vdouble x, vdouble y)
{
    return (vdouble){x.x1 + y.x1, x.x2 + y.x2};
}
```

I got

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

which include 4 extra instructions to align the stack without actually using
it....

FWIW, clang has a similar problem on linux...
https://bugs.llvm.org/show_bug.cgi?id=40844

Also worth noting that with -O2 all three vector instructions are splitted into
scalar ones whereas clang does this transformation at -O2...

Reply via email to