[clang] [llvm] [WIP] Correct lowering of `fp128` intrinsics (PR #76558)

Trevor Gross via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 21 17:52:13 PDT 2025


tgross35 wrote:

Talked to arsenm on discord, long discussion starting around here https://discord.com/channels/636084430946959380/636732535434510338/1362207130559578185. The outcome is that this is effectively a target option and needs to be tied to the triple rather than per-module. Which makes sense and avoids the above problem.

So, I'll be doing the following:

1. Make LLVM assume that `sqrtf128` (and similar) libcalls are available by default
2. On 64-bit arm, loongarch, mips, risc-v, and s390x musl targets, use `sqrtl` instead
3. Add some way to make musl targets also use `sqrtf128`, like `-nolongdouble` in the target triple

This should work because calling `sqrtf128` is correct on _most_ platforms:
* On Windows, Apple, and 32-bit platforms, `long double` is `f64` so `sqrtf128` is the only correct call
* On x86, `long double` is the x87 80-bit float so `sqrtf128` is the only correct call
* On anything glibc, `sqrtf128` is an alias to `sqrtl` on platforms where that works, so `sqrtf128` can always be called
* That leaves 64-bit `musl` on platforms where `long double` is `f128` as the only platforms where `sqrtl` has to be called (otherwise calling `sqrtl` from C would get intercepted and relowered as `sqrtf128` for a linker error)

https://github.com/llvm/llvm-project/pull/76558


More information about the llvm-commits mailing list