<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 - Passing small struct by value - suboptimal codegen"
   href="https://bugs.llvm.org/show_bug.cgi?id=52269">52269</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Passing small struct by value - suboptimal codegen
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>struct X
{
  char mem0[32];
  char mem1[32];
};


void bar (struct X);


void
foo1(struct X *x)
{
  bar(*x);
}




LLVM -O3 or even -Oz:
foo1:                                   # @foo1
        sub     rsp, 136
        movups  xmm0, xmmword ptr [rdi]
        movups  xmm1, xmmword ptr [rdi + 16]
        movups  xmm2, xmmword ptr [rdi + 32]
        movups  xmm3, xmmword ptr [rdi + 48]
        movaps  xmmword ptr [rsp + 112], xmm3
        movaps  xmmword ptr [rsp + 96], xmm2
        movaps  xmmword ptr [rsp + 80], xmm1
        movaps  xmmword ptr [rsp + 64], xmm0
        movaps  xmm0, xmmword ptr [rsp + 64]
        movaps  xmm1, xmmword ptr [rsp + 80]
        movaps  xmm2, xmmword ptr [rsp + 96]
        movaps  xmm3, xmmword ptr [rsp + 112]
        movups  xmmword ptr [rsp + 48], xmm3
        movups  xmmword ptr [rsp + 32], xmm2
        movups  xmmword ptr [rsp + 16], xmm1
        movups  xmmword ptr [rsp], xmm0
        call    bar
        add     rsp, 136
        ret


GCC:
foo1:
        sub     rsp, 72
        movdqu  xmm0, XMMWORD PTR [rdi]
        movdqu  xmm1, XMMWORD PTR [rdi+16]
        movdqu  xmm2, XMMWORD PTR [rdi+32]
        movdqu  xmm3, XMMWORD PTR [rdi+48]
        movups  XMMWORD PTR [rsp], xmm0
        movups  XMMWORD PTR [rsp+16], xmm1
        movups  XMMWORD PTR [rsp+32], xmm2
        movups  XMMWORD PTR [rsp+48], xmm3
        call    bar
        add     rsp, 72
        ret</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>