Skip to content

Commit 532002a

Browse files
committed
Use __builtin_elementwise_sqrt if available.
1 parent 177be88 commit 532002a

File tree

1 file changed

+8
-0
lines changed
  • libc/src/__support/FPUtil/aarch64

1 file changed

+8
-0
lines changed

libc/src/__support/FPUtil/aarch64/sqrt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,25 @@ namespace fputil {
2525

2626
#ifdef LIBC_TARGET_CPU_HAS_ARM_FPU_FLOAT
2727
template <> LIBC_INLINE float sqrt<float>(float x) {
28+
#if __has_builtin(__builtin_elementwise_sqrt)
29+
return __builtin_elementwise_sqrt(x);
30+
#else
2831
float y;
2932
asm("fsqrt %s0, %s1\n\t" : "=w"(y) : "w"(x));
3033
return y;
34+
#endif // __builtin_elementwise_sqrt
3135
}
3236
#endif // LIBC_TARGET_CPU_HAS_ARM_FPU_FLOAT
3337

3438
#ifdef LIBC_TARGET_CPU_HAS_ARM_FPU_DOUBLE
3539
template <> LIBC_INLINE double sqrt<double>(double x) {
40+
#if __has_builtin(__builtin_elementwise_sqrt)
41+
return __builtin_elementwise_sqrt(x);
42+
#else
3643
double y;
3744
asm("fsqrt %d0, %d1\n\t" : "=w"(y) : "w"(x));
3845
return y;
46+
#endif // __builtin_elementwise_sqrt
3947
}
4048
#endif // LIBC_TARGET_CPU_HAS_ARM_FPU_DOUBLE
4149

0 commit comments

Comments
 (0)