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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libc/src/__support/FPUtil/sqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80

} // namespace fputil
} // namespace LIBC_NAMESPACE_DECL

Expand Down
Loading