[PATCH] D157836: [RFC][IR] Correct lowering of `f128` intrinsics
Trevor Gross via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 00:45:03 PDT 2023
tmgross created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
tmgross retitled this revision from "[IR] Add an xpassing test for `f128` intrinsic lowering" to "[RFC][IR] Correct lowering of `f128` intrinsics".
tmgross edited the summary of this revision.
tmgross added reviewers: RKSimon, pengfei, ldionne.
tmgross added subscribers: RKSimon, ldionne.
tmgross added a subscriber: llvm-commits.
tmgross published this revision for review.
Herald added a project: LLVM.
[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 at 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.
Fixes https://github.com/llvm/llvm-project/issues/44744
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157836
Files:
llvm/include/llvm/IR/RuntimeLibcalls.def
llvm/test/CodeGen/X86/f128-arith.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157836.549808.patch
Type: text/x-patch
Size: 22237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230814/b14da898/attachment.bin>
More information about the llvm-commits
mailing list