<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Unneeded stack alignment on x86"
   href="https://bugs.llvm.org/show_bug.cgi?id=40844">40844</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unneeded stack alignment on x86
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yyc1992@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Ref <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Vector ABI does not respect target attribute"
   href="show_bug.cgi?id=40843">https://bugs.llvm.org/show_bug.cgi?id=40843</a>. The useless stack operations
are likely caused by a different issue...

Reproducible with C code,

```
typedef double _vdouble __attribute__((vector_size(32)));

typedef struct {
    _vdouble x;
    int y;
} vdouble;

vdouble f(vdouble x, vdouble y)
{
    vdouble res = {x.x + y.x, x.y + y.y};
    return res;
}
```

Compiling with clang with `-mavx` emits very similar code to GCC

```
f:                                      # @f
# %bb.0:
        pushq   %rbp
        movq    %rsp, %rbp
        andq    $-32, %rsp
        subq    $32, %rsp
        vmovapd 16(%rbp), %ymm0
        vaddpd  80(%rbp), %ymm0, %ymm0
        vmovapd %ymm0, (%rdi)
        movl    112(%rbp), %eax
        addl    48(%rbp), %eax
        movl    %eax, 32(%rdi)
        movq    %rdi, %rax
        movq    %rbp, %rsp
        popq    %rbp
        vzeroupper
        retq
```

except that it emits 6 additional instructions for stack realignment without
actually using the stack pointer anywhere else in the function.

Seems to be a x86 backend issue since I can reproduce even without enabling avx
(so nothing in the backend should require 32bit alignment, only the frontend
should) and I can't reproduce on arm or aarch64.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>