-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc] Extend fputil::sqrt to use floating point instructions for arm32. #134499
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
Changes from 5 commits
3f76cdf
3be70f1
b97174a
0590dba
70927af
51014dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,44 @@ | |
| #include "src/__support/macros/properties/architectures.h" | ||
| #include "src/__support/macros/properties/cpu_features.h" | ||
|
|
||
| #if defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE2) | ||
| #include "src/__support/FPUtil/generic/sqrt.h" | ||
|
|
||
| // Generic instruction specializations with __builtin_elementwise_sqrt. | ||
| #if defined(LIBC_TARGET_CPU_HAS_FPU_FLOAT) || \ | ||
| defined(LIBC_TARGET_CPU_HAS_FPU_DOUBLE) | ||
|
|
||
| #if __has_builtin(__builtin_elementwise_sqrt) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clang will always evaluate this to I think we'll need a CMake check that compiles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like |
||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
| namespace fputil { | ||
|
|
||
| #ifdef LIBC_TARGET_CPU_HAS_FPU_FLOAT | ||
| template <> LIBC_INLINE float sqrt<float>(float x) { | ||
| return __builtin_elementwise_sqrt(x); | ||
| } | ||
| #endif // LIBC_TARGET_CPU_HAS_FPU_FLOAT | ||
|
|
||
| #ifdef LIBC_TARGET_CPU_HAS_FPU_DOUBLE | ||
| template <> LIBC_INLINE double sqrt<double>(double x) { | ||
| return __builtin_elementwise_sqrt(x); | ||
| } | ||
| #endif // LIBC_TARGET_CPU_HAS_FPU_DOUBLE | ||
|
|
||
| } // namespace fputil | ||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #else | ||
lntue marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Use inline assembly when __builtin_elementwise_sqrt is not available. | ||
| #if defined(LIBC_TARGET_CPU_HAS_SSE2) | ||
| #include "x86_64/sqrt.h" | ||
| #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) | ||
| #include "aarch64/sqrt.h" | ||
| #elif defined(LIBC_TARGET_ARCH_IS_ANY_ARM) | ||
| #include "arm/sqrt.h" | ||
| #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) | ||
| #include "riscv/sqrt.h" | ||
| #else | ||
| #include "generic/sqrt.h" | ||
| #endif // Target specific header of inline asm. | ||
|
|
||
| #endif // __builtin_elementwise_sqrt | ||
|
|
||
| #endif // LIBC_TARGET_CPU_HAS_FPU_FLOAT or DOUBLE | ||
|
|
||
| #endif | ||
| #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_SQRT_H | ||
Uh oh!
There was an error while loading. Please reload this page.