[IR] Correct lowering of f128 intrinsics
Change the lowering of 128-bit floating point math function intrinsics
to use binary128 functions (sqrtf128) rather than long double
functions (sqrtl).
Currently intrinsic calls such as @llvm.sqrt.f128 are lowered to
libc's long double functions. On platforms where long double is
not fp128, this results in incorrect math.
define fp128 @test_sqrt(fp128 %a) { start: %0 = tail call fp128 @llvm.sqrt.f128(fp128 %a) ret fp128 %0 } declare fp128 @llvm.sqrt.f128(fp128)
lowers to
test_sqrt: # @test_sqrt jmp sqrtl@PLT # TAILCALL
On x86 this results in the binary128 argument being treated as 80-bit
extended precision.
This has no effect on clang, which lowers builtins to the libc calls
directly without going through LLVM intrinsics.