Repository navigation
Invalid lowering of llvm.*.f128 intrinsics #44744
Description
Activity
I started a patch for this here https://reviews.llvm.org/D157836
39 remaining items
This has been resolved since LLVM 19 https://godbolt.org/z/xGT7EKfd6. The default lowering uses a libcall.
bad_lowering: # @bad_lowering jmp sinf128@PLT # TAILCALL manual_correct_lowering: # @manual_correct_lowering subq $24, %rsp callq __trunctfxf2@PLT fstpt (%rsp) callq sinl@PLT fstpt (%rsp) callq __extendxftf2@PLT addq $24, %rsp retq
That's only on linux-gnu (IIRC there's an exception in the code), all other targets are still borked https://godbolt.org/z/PWdvEKdbM
- added 7 commits that reference this issue
on Jul 1, 2026 - added a commit that references this issue
on Aug 16, 2026 @arsenm thanks for your work on gradually fixing this!
From reading the commits though, it seems like LLVM will now error when the required libcall is not available. That sort of makes sense from the LLVM perspective, but for Rust (and I assume other frontends) we'd rather that it turns into a linker error, so that rust's
compiler-builtinscan provide its own implementation where needed.Rust aims to provide the
f128type across targets, not just on targets where it corresponds tolong doubleor even just targets where Clang defined__float128or_Float128. All targets. Hence we need a mechanism to provide the libcalls where the platform doesn't have them (yet).It's kind of terrible that compiler-rt is being treated as a static, unmaintained thing and worked around with external components.
However, I am working towards a generalized mechanism for pluggable runtime libraries. I have most of the core infrastructure implemented (#217592 is part 1). When it's done you'll be able to declare what compiler-builtins provides in tablegen and specify a module flag indicating it will be linked
Reacted by Trevor Gross
Extended Description
llvm.sin.f128 is incorrectly lowered to a call to sinl, which takes a f80: https://godbolt.org/z/M9fjLW
generates:
which is missing conversions from and to x86_fp80.
I expect a correct lowering to be: