[libc-commits] [libc] f726b86 - [libc] Only use the x86_64 sqrt inline asm on x86_64 (#218721)
via libc-commits
libc-commits at lists.llvm.org
Wed Aug 26 01:41:05 PDT 2026
Author: Lewis Crawford
Date: 2026-08-26T09:41:01+01:00
New Revision: f726b86aefcd0961df571d87b06e344350809f54
URL: https://github.com/llvm/llvm-project/commit/f726b86aefcd0961df571d87b06e344350809f54
DIFF: https://github.com/llvm/llvm-project/commit/f726b86aefcd0961df571d87b06e344350809f54.diff
LOG: [libc] Only use the x86_64 sqrt inline asm on x86_64 (#218721)
x86_64/sqrt.h is included whenever SSE2 is available, but it #errors out
unless the target is x86_64. This breaks 32-bit x86 builds which enable
SSE2 (e.g. -march=pentium4 -mfpmath=sse), so also require x86_64 here
and let 32-bit x86 use the unconditionally-included generic/sqrt.h
instead.
Added:
Modified:
libc/src/__support/FPUtil/sqrt.h
Removed:
################################################################################
diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h
index b06503bca4e5b..fbc279a128ff7 100644
--- a/libc/src/__support/FPUtil/sqrt.h
+++ b/libc/src/__support/FPUtil/sqrt.h
@@ -48,7 +48,7 @@ template <> LIBC_INLINE long double sqrt<long double>(long double x) {
#else // __builtin_elementwise_sqrt
// Use inline assembly when __builtin_elementwise_sqrt is not available.
-#if defined(LIBC_TARGET_CPU_HAS_SSE2)
+#if defined(LIBC_TARGET_CPU_HAS_SSE2) && defined(LIBC_TARGET_ARCH_IS_X86_64)
#include "x86_64/sqrt.h"
#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP)
#include "aarch64/sqrt.h"
More information about the libc-commits
mailing list