https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054
--- Comment #8 from Trevor Gross <tmgross at umich dot edu> --- After some more digging it sounds like passing _Float128 arguments indirectly is the correct thing to do, which is GCC's current behavior. Excerpts from the calling convention [1]: > Integer arguments are passed in registers RCX, RDX, R8, and R9. > Floating point arguments are passed in XMM0L, XMM1L, XMM2L, and XMM3L. > 16-byte arguments are passed by reference. And > __m128 types, arrays, and strings are never passed by immediate > value. Instead, a pointer is passed to memory allocated by the > caller. Additionally, varargs don't work correctly if _Float128 is passed by value (thanks lh_mouse on IRC for pointing this out). So GCC is doing the right thing for arguments, and I have a WIP patch to make LLVM agree [2]. However, the return section of the calling convention says the following: > A scalar return value that can fit into 64 bits, including the __m64 > type, is returned through RAX. Non-scalar types including floats, > doubles, and vector types such as __m128, __m128i, __m128d are > returned in XMM0. My read of that is that even though _Float128 needs to be passed indirectly, it should be returned in XMM0. GCC currently returns on the stack so I am thinking this should change. This would make _Float128 share the same calling convention as __m128. For _Float16, it seems like following _Float32/_Float64 would be reasonable since the calling convention generally seems to indicate that floats get passed in vector registers, and it fits. In short, the changes I would propose are: - GCC change to return _Float128 in XMM0, continue passing on the stack - GCC change to pass and return _Float16 in XMM - Clang change to pass _Float128 indirectly, continue returning in XMM0 Obviously there is some extrapolations here since the type isn't officially supported, but this seems more or less consistent with existing types. Andrew, do you have any thoughts here? [1]: https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170 [2]: https://github.com/llvm/llvm-project/pull/115052