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

    <tr>
        <th>Summary</th>
        <td>
            struct {__float128} on should be passed in registers on X86-64 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:X86,
            clang:codegen
      </td>
    </tr>

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

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

<pre>
    I am working on flang, and we have to deal with struct passing ABI in the context of C/Fortran interoperability.
I noticed that `struct {__float128}` are passed on the stack (byval) by clang on X86-64. Reading at the ABI, I would expect them to be passed in SSE register.

```
typedef struct {
 __float128 x;
} S;

void bar(__float128 x);

void test(S x) {
 bar(x.x);
}
```

LLVM IR for X86-64:
```
define dso_local void @test(ptr noundef byval(%struct.S) align 16 %0)  {
  %2 = getelementptr inbounds %struct.S, ptr %0, i32 0, i32 0
  %3 = load fp128, ptr %2, align 16
  call void @bar(fp128 noundef %3)
  ret void
}
declare void @bar(fp128 noundef)
```

`clang -O3` Assembly:
```
test:                                   # @test
 movaps  xmm0, xmmword ptr [rsp + 8]
        jmp     bar@PLT 
```

For info, `gcc -O3` / `icc -O3` assembly looks like:
```
test:
        jmp     bar
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE1v4zgM_TXyhWhgy589-JA0GyBAFzuYLBZzK2SLdtTIkiEpX_9-IdltmkE7NQI5psjH90iCzFrRK8Sa5CuSryN2dHtt6ldk6gcagSZqNL_WW2ADnLU5CNWDVtBJpnpCn4ApDmeEPTshOA0cmYSzcHuwzhxbB6NPoHpYrrYgFLg9QquVw4sD3cEToZuNNs4wBUI5NHpEwxohhbsuSLwm8XILSjvRIge3Zw5IEc_IpFy9vHRSM5fQipRrUsTADIaMyD1Jn8w61h6A0Kq5npgk9BGaK7Sevff4VRUPRbaAn8i4Z8lcCFqutl7bF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