[libc-commits] [libc] [libc][math] Add x86-64 sqrt specialization for 80-bit long double. (PR #139203)
via libc-commits
libc-commits at lists.llvm.org
Thu May 8 20:52:44 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (lntue)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/139203.diff
1 Files Affected:
- (modified) libc/src/__support/FPUtil/sqrt.h (+8)
``````````diff
diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h
index 1d377ab9a4e2d..0e6be73b66018 100644
--- a/libc/src/__support/FPUtil/sqrt.h
+++ b/libc/src/__support/FPUtil/sqrt.h
@@ -35,6 +35,14 @@ template <> LIBC_INLINE double sqrt<double>(double x) {
}
#endif // LIBC_TARGET_CPU_HAS_FPU_DOUBLE
+// Use 80-bit long double instruction on x86.
+// https://godbolt.org/z/oWEaj6hxK
+#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
+template <> LIBC_INLINE long double sqrt<long double>(long double x) {
+ return __builtin_elementwise_sqrt(x);
+}
+#endif
+
} // namespace fputil
} // namespace LIBC_NAMESPACE_DECL
``````````
</details>
https://github.com/llvm/llvm-project/pull/139203
More information about the libc-commits
mailing list