<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - psABI inconsistency when passing vector registers?"
   href="https://llvm.org/bugs/show_bug.cgi?id=29092">29092</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>psABI inconsistency when passing vector registers?
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>wenzel.jakob@epfl.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang trunk does not pass vector types through registers when they are
contained in an aggregate data type. Consider the following simple program:

------------------------------
C code:

#include <immintrin.h>

typedef struct __attribute__((aligned(16))) {
    __m128 x, y;
} Structure;


__m128 test1(__m128 x, __m128 y) { return y; }
__m128 test2(Structure t) { return t.y; }

------------------------------

Assembly:

$ clang++ test.cpp -msse4.2 -I include -std=c++14 -o - -S -fomit-frame-pointer
-O3

__Z5test1Dv4_fS_:
           vmovaps    %xmm1, %xmm0
           retq

__Z5test29Structure: 
           vmovaps    24(%rsp), %xmm0       <------ copy from memory :(
           retq

------------------------------

The psABI spec
(<a href="https://github.com/hjl-tools/x86-psABI/blob/master/low-level-sys-info.tex#L506">https://github.com/hjl-tools/x86-psABI/blob/master/low-level-sys-info.tex#L506</a>)
has the following to say about this:

Each field of an object is classified *recursively* (emphasis added) so that
always two fields are considered. The resulting class is calculated according
to the classes of the fields in the eightbyte [...]. 
(a)-(e) [... cases which don't apply ...]
(f) Otherwise class SSE is used.


Intuitively (and according to the spec), I would have expected that "x" is
assigned to %xmm0 and "y" is assigned to %xmm1.

I'm wondering if I am misreading the ABI here, or if Clang is in violation?</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>