-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86][CodeGen] Emit float128 libcalls for math functions #79611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-llvm-ir Author: Pranav Kant (pranavk) ChangesMake LLVM emit libcalls to proper float128 variants for float128 types. There are many other variants that may require this change. I am just putting this out for now to enable it for simple functions that are blocking me. Full diff: https://github.com/llvm/llvm-project/pull/79611.diff 1 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.def b/llvm/include/llvm/IR/RuntimeLibcalls.def
index 19dea60bebf9be5..01cab92bf8414d8 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.def
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.def
@@ -252,17 +252,17 @@ HANDLE_LIBCALL(FLOOR_PPCF128, "floorl")
HANDLE_LIBCALL(COPYSIGN_F32, "copysignf")
HANDLE_LIBCALL(COPYSIGN_F64, "copysign")
HANDLE_LIBCALL(COPYSIGN_F80, "copysignl")
-HANDLE_LIBCALL(COPYSIGN_F128, "copysignl")
+HANDLE_LIBCALL(COPYSIGN_F128, "copysignf128")
HANDLE_LIBCALL(COPYSIGN_PPCF128, "copysignl")
HANDLE_LIBCALL(FMIN_F32, "fminf")
HANDLE_LIBCALL(FMIN_F64, "fmin")
HANDLE_LIBCALL(FMIN_F80, "fminl")
-HANDLE_LIBCALL(FMIN_F128, "fminl")
+HANDLE_LIBCALL(FMIN_F128, "fminf128")
HANDLE_LIBCALL(FMIN_PPCF128, "fminl")
HANDLE_LIBCALL(FMAX_F32, "fmaxf")
HANDLE_LIBCALL(FMAX_F64, "fmax")
HANDLE_LIBCALL(FMAX_F80, "fmaxl")
-HANDLE_LIBCALL(FMAX_F128, "fmaxl")
+HANDLE_LIBCALL(FMAX_F128, "fmaxf128")
HANDLE_LIBCALL(FMAX_PPCF128, "fmaxl")
HANDLE_LIBCALL(LROUND_F32, "lroundf")
HANDLE_LIBCALL(LROUND_F64, "lround")
|
This LGTM, but we'd need My digging into the log says that 4bf47bc (2013) (@TNorthover) introduced these l libcall names. aarch64 long double is quad precision and its glibc only introduced |
41c19c8
to
3ff2c65
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
@MaskRay clang codegens correct LLVM IR. So I don't think we need any more tests in clang/test/CodeGen/. All the fp128 __builtin tests we have there already check for generation of appropriate fp128 LLVM IR calls (https://github.com/llvm/llvm-project/blob/3d71e4166de81bc3b86d127d9ac6607bda2b2755/clang/test/CodeGen/X86/math-builtins.c) The problem is in lowering of LLVM IR into machine code which is what this patch is trying to fix for X86_64. I have changed the tests to check for that lowering. |
Also worth noting that x86 codegen for fp128 in clang right now seems completely broken because LLVM lowers to fFOOl variants without proper casting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Otherwise it breaks some environment like X64 Android that doesn't have f128 functions available in its libc. Followup to #79611.
Make LLVM emit libcalls to proper float128 variants for float128 types.