<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62994>62994</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [x86] Incorrect 32-bit ABI for vector_size(8)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          easyaspi314
      </td>
    </tr>
</table>

<pre>
    According to the SysV ABI, 8 byte vectors are to be passed in mm0-mm2 and returned in mm0, and this is the only scenario where a function is called and/or returned in MMX mode. 

Currently it seems to be quite random:

| base type | simd | pass | return |
| :-- | :-- | :-- | :-- |
| float | none | stack | st0:st1 |
| float | sse | xmm0-2 | xmm0 |
| double | any | stack | st0 |
| int64, __m64 | any | stack | eax:edx |
| int < 64 | none | stack | stack |
| int < 64 | sse2 | stack | xmm0 |

Of course this would need to be handled carefully since EMMS is required.

A simple , albeit a bit inefficient, solution is to treat the function like it takes XMM registers and hardcode a prologue and epilogue to switch between them. Perhaps this could be optimized out if there is a direct bitcast to/from x86_mmx.
```asm
caller:
    ...
    movdq2q mm0, xmm0
 movdq2q mm1, xmm1
    call   callee
    movq2dq xmm0, mm0
    emms
 ...
callee:
    movq2dq xmm0, mm0
    movq2dq xmm1, mm1
    emms
 ...
    movdq2q mm0, xmm0
    ret
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE-Po7gT_TTOpRRkDOFHDhzozC9SH6JdaaTV3FrGLoK3_YfYppPMp18ZmO7Mbs-uhES5qt5zVfnZPAR1togN2T2R3ZcNn-LgfIM83HkYVZGXm87Je9MK4bxU9gzRQRwQvt7DH9A-PRN2gBq6e0R4QxGdD8A9pqwOYeQhoARlwRi6NYYBtxI8xsnbd39iSO44qAAqzOzO6jsEgZZ75eA6oEfg0E9WROVsyhJca5QJSNjR-Z9IT6dvYJzEDAhtCW0Pk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