Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[libc][math] Add x86-64 sqrt specialization for 80-bit long double. #139203

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

Merged
merged 2 commits into from
May 9, 2025

Conversation

lntue
Copy link
Contributor

@lntue lntue commented May 9, 2025

No description provided.

@lntue lntue requested review from vonosmas and michaelrj-google May 9, 2025 03:52
@llvmbot llvmbot added the libc label May 9, 2025
@llvmbot
Copy link
Member

llvmbot commented May 9, 2025

@llvm/pr-subscribers-libc

Author: None (lntue)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/139203.diff

1 Files Affected:

  • (modified) libc/src/__support/FPUtil/sqrt.h (+8)
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
 

@lntue lntue requested a review from rupprecht May 9, 2025 03:55
@lntue lntue merged commit a179a1b into llvm:main May 9, 2025
16 checks passed
@lntue lntue deleted the sqrt branch May 9, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants