[libc-commits] [libc] [libc][arm64ec] Make Arm64EC its own architecture in libc instead of defaulting to x64 (PR #227093)

Daniel Paoliello via libc-commits libc-commits at lists.llvm.org
Tue Oct 6 10:52:46 PDT 2026


https://github.com/dpaoliello updated https://github.com/llvm/llvm-project/pull/227093

>From 3578240cda44ae8f904a42308f27fd4d7c880383 Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Fri, 25 Sep 2026 16:20:18 -0700
Subject: [PATCH 1/3] [libc][arm64ec] Make Arm64EC its own architecture in libc
 instead of defaulting to x64

---
 libc/src/__support/FPUtil/BasicOperations.h          |  6 ++++--
 libc/src/__support/FPUtil/FEnvImpl.h                 |  4 +++-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h         |  4 +++-
 libc/src/__support/FPUtil/aarch64/nearest_integer.h  |  3 ++-
 libc/src/__support/FPUtil/aarch64/sqrt.h             |  3 ++-
 libc/src/__support/FPUtil/nearest_integer.h          |  8 ++++++--
 libc/src/__support/FPUtil/sqrt.h                     |  8 ++++++--
 libc/src/__support/macros/properties/architectures.h | 10 ++++++++--
 libc/src/__support/macros/properties/cpu_features.h  |  4 +++-
 libc/src/__support/threads/sleep.h                   |  7 +++++--
 libc/src/__support/threads/thread_attributes.h       |  1 +
 libc/src/string/memory_utils/inline_bcmp.h           |  3 ++-
 libc/src/string/memory_utils/inline_memcmp.h         |  3 ++-
 libc/src/string/memory_utils/inline_memcpy.h         |  3 ++-
 libc/src/string/memory_utils/inline_memmove.h        |  3 ++-
 libc/src/string/memory_utils/inline_memset.h         |  3 ++-
 libc/src/string/memory_utils/op_aarch64.h            |  2 +-
 libc/src/string/string_length.h                      |  3 ++-
 libc/test/UnitTest/FEnvSafeTest.cpp                  |  5 +++--
 libc/test/src/string/memory_utils/op_tests.cpp       |  4 ++--
 20 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index 5b81b921296a04..a03c28b634cb98 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -59,7 +59,8 @@ template <> LIBC_INLINE constexpr float16 max(float16 x, float16 y) {
     return constexpr_max(x, y);
   return __builtin_fmaxf16(x, y);
 }
-#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64) &&                                 \
+    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 template <> LIBC_INLINE constexpr float16 max(float16 x, float16 y) {
   FPBits<float16> x_bits(x);
   FPBits<float16> y_bits(y);
@@ -112,7 +113,8 @@ template <> LIBC_INLINE constexpr float16 min(float16 x, float16 y) {
     return constexpr_min(x, y);
   return __builtin_fminf16(x, y);
 }
-#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64) &&                                 \
+    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 template <> LIBC_INLINE constexpr float16 min(float16 x, float16 y) {
   FPBits<float16> x_bits(x);
   FPBits<float16> y_bits(y);
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 6f77ce44c705a9..970258624c8f9b 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -101,7 +101,9 @@ LIBC_INLINE int set_env(const fenv_t *env) {
 
 #else // !LIBC_MATH_USE_SYSTEM_FENV
 
-#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP)
+#if (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                   \
+     defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                  \
+    defined(__ARM_FP)
 #if defined(__APPLE__)
 #include "aarch64/fenv_darwin_impl.h"
 #else
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index 18182ed977cce5..66d5a39d8630b0 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -13,7 +13,9 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/architectures.h"
 
-#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(__APPLE__)
+#if (!defined(LIBC_TARGET_ARCH_IS_AARCH64) &&                                  \
+     !defined(LIBC_TARGET_ARCH_IS_ARM64EC)) ||                                 \
+    defined(__APPLE__)
 #error "Invalid include"
 #endif
 
diff --git a/libc/src/__support/FPUtil/aarch64/nearest_integer.h b/libc/src/__support/FPUtil/aarch64/nearest_integer.h
index d5ea0678825fdd..2815cef1228beb 100644
--- a/libc/src/__support/FPUtil/aarch64/nearest_integer.h
+++ b/libc/src/__support/FPUtil/aarch64/nearest_integer.h
@@ -13,7 +13,8 @@
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/architectures.h"
 
-#if !defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) &&                                   \
+    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #error "Invalid include"
 #endif
 
diff --git a/libc/src/__support/FPUtil/aarch64/sqrt.h b/libc/src/__support/FPUtil/aarch64/sqrt.h
index 4eb576bf2244c6..fe6752af553a33 100644
--- a/libc/src/__support/FPUtil/aarch64/sqrt.h
+++ b/libc/src/__support/FPUtil/aarch64/sqrt.h
@@ -14,7 +14,8 @@
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/cpu_features.h"
 
-#if !defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) &&                                   \
+    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #error "Invalid include"
 #endif
 
diff --git a/libc/src/__support/FPUtil/nearest_integer.h b/libc/src/__support/FPUtil/nearest_integer.h
index fabd309bd35202..c13cb1ba3043b3 100644
--- a/libc/src/__support/FPUtil/nearest_integer.h
+++ b/libc/src/__support/FPUtil/nearest_integer.h
@@ -14,9 +14,13 @@
 #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_SSE4_2))
+#if defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                     \
+    defined(LIBC_TARGET_CPU_HAS_SSE4_2) &&                                     \
+    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "x86_64/nearest_integer.h"
-#elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP))
+#elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                 \
+       defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                \
+    defined(__ARM_FP)
 #include "aarch64/nearest_integer.h"
 #elif defined(LIBC_TARGET_ARCH_IS_GPU)
 
diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h
index fbc279a128ff7e..e6d656c5a142e2 100644
--- a/libc/src/__support/FPUtil/sqrt.h
+++ b/libc/src/__support/FPUtil/sqrt.h
@@ -48,9 +48,13 @@ 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) && defined(LIBC_TARGET_ARCH_IS_X86_64)
+#if defined(LIBC_TARGET_CPU_HAS_SSE2) &&                                       \
+    defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                     \
+    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "x86_64/sqrt.h"
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP)
+#elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                 \
+       defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                \
+    defined(__ARM_FP)
 #include "aarch64/sqrt.h"
 #elif defined(LIBC_TARGET_ARCH_IS_ARM)
 #include "arm/sqrt.h"
diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
index f73fa7a7643ab6..514d1adcfeeb46 100644
--- a/libc/src/__support/macros/properties/architectures.h
+++ b/libc/src/__support/macros/properties/architectures.h
@@ -34,7 +34,12 @@
 #define LIBC_TARGET_ARCH_IS_X86_32
 #endif
 
-#if (defined(_M_X64) || defined(__x86_64__)) && !defined(LIBC_TARGET_ARCH_IS_VM)
+#if defined(__arm64ec__) || defined(_M_ARM64EC)
+#define LIBC_TARGET_ARCH_IS_ARM64EC
+#endif
+
+#if (defined(_M_X64) || defined(__x86_64__)) &&                                \
+    !defined(LIBC_TARGET_ARCH_IS_VM) && !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #define LIBC_TARGET_ARCH_IS_X86_64
 #endif
 
@@ -54,7 +59,8 @@
 #define LIBC_TARGET_ARCH_IS_AARCH64
 #endif
 
-#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM)
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                    \
+    defined(LIBC_TARGET_ARCH_IS_ARM) || defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #define LIBC_TARGET_ARCH_IS_ANY_ARM
 #endif
 
diff --git a/libc/src/__support/macros/properties/cpu_features.h b/libc/src/__support/macros/properties/cpu_features.h
index 77daeb7c1fcc22..89de846b838c78 100644
--- a/libc/src/__support/macros/properties/cpu_features.h
+++ b/libc/src/__support/macros/properties/cpu_features.h
@@ -137,12 +137,14 @@
 #endif
 
 #if defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                    \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC) ||                                    \
     (defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                    \
      defined(LIBC_TARGET_CPU_HAS_SSE4_2))
 #define LIBC_TARGET_CPU_HAS_NEAREST_INT
 #endif
 
-#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_GPU)
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                    \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC) || defined(LIBC_TARGET_ARCH_IS_GPU)
 #define LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS
 #endif
 
diff --git a/libc/src/__support/threads/sleep.h b/libc/src/__support/threads/sleep.h
index 777283356b58e0..b9a2e191473ec4 100644
--- a/libc/src/__support/threads/sleep.h
+++ b/libc/src/__support/threads/sleep.h
@@ -23,9 +23,12 @@ LIBC_INLINE void sleep_briefly() {
   __builtin_amdgcn_s_sleep(2);
 #elif defined(LIBC_TARGET_ARCH_IS_X86)
   __builtin_ia32_pause();
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) && __has_builtin(__builtin_arm_isb)
+#elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                 \
+       defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                \
+    __has_builtin(__builtin_arm_isb)
   __builtin_arm_isb(0xf);
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                  \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC)
   asm volatile("isb\n" ::: "memory");
 #else
   // Simply do nothing if sleeping isn't supported on this platform.
diff --git a/libc/src/__support/threads/thread_attributes.h b/libc/src/__support/threads/thread_attributes.h
index bffdbc616ccb39..08c5c582be46c2 100644
--- a/libc/src/__support/threads/thread_attributes.h
+++ b/libc/src/__support/threads/thread_attributes.h
@@ -41,6 +41,7 @@ union ThreadReturnValue {
 };
 
 #if (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                   \
+     defined(LIBC_TARGET_ARCH_IS_ARM64EC) ||                                   \
      defined(LIBC_TARGET_ARCH_IS_X86_64) ||                                    \
      defined(LIBC_TARGET_ARCH_IS_ANY_RISCV))
 constexpr unsigned int STACK_ALIGNMENT = 16;
diff --git a/libc/src/string/memory_utils/inline_bcmp.h b/libc/src/string/memory_utils/inline_bcmp.h
index d6d3c9c1a3ad8c..a9e73213743c36 100644
--- a/libc/src/string/memory_utils/inline_bcmp.h
+++ b/libc/src/string/memory_utils/inline_bcmp.h
@@ -22,7 +22,8 @@
 #elif defined(LIBC_TARGET_ARCH_IS_X86)
 #include "src/string/memory_utils/x86_64/inline_bcmp.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_x86
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                  \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "src/string/memory_utils/aarch64/inline_bcmp.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_aarch64_dispatch
 #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
diff --git a/libc/src/string/memory_utils/inline_memcmp.h b/libc/src/string/memory_utils/inline_memcmp.h
index a98f7ac51648e8..7757f385b7d204 100644
--- a/libc/src/string/memory_utils/inline_memcmp.h
+++ b/libc/src/string/memory_utils/inline_memcmp.h
@@ -21,7 +21,8 @@
 #elif defined(LIBC_TARGET_ARCH_IS_X86)
 #include "src/string/memory_utils/x86_64/inline_memcmp.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_x86
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                  \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "src/string/memory_utils/aarch64/inline_memcmp.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_aarch64_dispatch
 #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
diff --git a/libc/src/string/memory_utils/inline_memcpy.h b/libc/src/string/memory_utils/inline_memcpy.h
index 6924339927a358..e7573800c031b4 100644
--- a/libc/src/string/memory_utils/inline_memcpy.h
+++ b/libc/src/string/memory_utils/inline_memcpy.h
@@ -28,7 +28,8 @@
 #elif defined(LIBC_TARGET_ARCH_IS_ARM)
 #include "src/string/memory_utils/arm/inline_memcpy.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_arm
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                  \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "src/string/memory_utils/aarch64/inline_memcpy.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_aarch64
 #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
diff --git a/libc/src/string/memory_utils/inline_memmove.h b/libc/src/string/memory_utils/inline_memmove.h
index c75100b48cc95b..e3142bd6f51737 100644
--- a/libc/src/string/memory_utils/inline_memmove.h
+++ b/libc/src/string/memory_utils/inline_memmove.h
@@ -24,7 +24,8 @@
   inline_memmove_small_size_x86
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP                         \
   inline_memmove_follow_up_x86
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                  \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "src/string/memory_utils/aarch64/inline_memmove.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE                        \
   inline_memmove_no_small_size
diff --git a/libc/src/string/memory_utils/inline_memset.h b/libc/src/string/memory_utils/inline_memset.h
index 1043077817fcc7..8cb219f27e6abe 100644
--- a/libc/src/string/memory_utils/inline_memset.h
+++ b/libc/src/string/memory_utils/inline_memset.h
@@ -24,7 +24,8 @@
 #elif defined(LIBC_TARGET_ARCH_IS_ARM)
 #include "src/string/memory_utils/arm/inline_memset.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_arm_dispatch
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                  \
+    defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 #include "src/string/memory_utils/aarch64/inline_memset.h"
 #define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_aarch64_dispatch
 #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
diff --git a/libc/src/string/memory_utils/op_aarch64.h b/libc/src/string/memory_utils/op_aarch64.h
index 4e116bc8a5e3ce..288b262b123436 100644
--- a/libc/src/string/memory_utils/op_aarch64.h
+++ b/libc/src/string/memory_utils/op_aarch64.h
@@ -18,7 +18,7 @@
 #include "src/__support/macros/is_defined.h"
 #include "src/__support/macros/properties/architectures.h"
 
-#if defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM64EC)
 
 #include "src/__support/CPP/type_traits.h" // cpp::always_false
 #include "src/__support/common.h"
diff --git a/libc/src/string/string_length.h b/libc/src/string/string_length.h
index 089c76b8eab96b..ba4bc02c6a4897 100644
--- a/libc/src/string/string_length.h
+++ b/libc/src/string/string_length.h
@@ -24,7 +24,8 @@
 #endif
 #if defined(LIBC_TARGET_ARCH_IS_X86)
 #include "src/string/memory_utils/x86_64/inline_strlen.h"
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) &&                                  \
+#elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                 \
+       defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                \
     (defined(LIBC_TARGET_CPU_HAS_SVE) || defined(__ARM_NEON))
 #include "src/string/memory_utils/aarch64/inline_strlen.h"
 #endif
diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp
index e8f498af6e2605..8ab6355f304f16 100644
--- a/libc/test/UnitTest/FEnvSafeTest.cpp
+++ b/libc/test/UnitTest/FEnvSafeTest.cpp
@@ -45,8 +45,9 @@ void FEnvSafeTest::expect_fenv_eq([[maybe_unused]] const fenv_t &before_fenv,
                                   [[maybe_unused]] const fenv_t &after_fenv) {
 #ifndef LIBC_MATH_USE_SYSTEM_FENV
 
-#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && !defined(LIBC_COMPILER_IS_MSVC) && \
-    defined(__ARM_FP)
+#if (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                   \
+     defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                  \
+    !defined(LIBC_COMPILER_IS_MSVC) && defined(__ARM_FP)
   using FPState = LIBC_NAMESPACE::fputil::FEnv::FPState;
   const FPState &before_state = reinterpret_cast<const FPState &>(before_fenv);
   const FPState &after_state = reinterpret_cast<const FPState &>(after_fenv);
diff --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp
index 9d26056a720f3a..9c50a8f45d1b40 100644
--- a/libc/test/src/string/memory_utils/op_tests.cpp
+++ b/libc/test/src/string/memory_utils/op_tests.cpp
@@ -215,7 +215,7 @@ using BcmpImplementations = testing::TypeList<
 #endif // __AVX512BW__
 
 #endif // LIBC_TARGET_ARCH_IS_X86_64
-#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM64EC)
     aarch64::Bcmp<16>, //
     aarch64::Bcmp<32>,
 #endif
@@ -309,7 +309,7 @@ using MemcmpImplementations = testing::TypeList<
     generic::Memcmp<__m512i>, //
 #endif
 #endif // LIBC_TARGET_ARCH_IS_X86_64
-#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM64EC)
     generic::Memcmp<uint8x16_t>, //
     generic::Memcmp<uint8x16x2_t>,
 #endif

>From d9150335758275cb2e516afdd47578237cc38f8e Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Tue, 6 Oct 2026 10:26:11 -0700
Subject: [PATCH 2/3] Remove redundant checks for `x64 && !Arm64EC`

---
 libc/src/__support/FPUtil/nearest_integer.h          | 4 +---
 libc/src/__support/FPUtil/sqrt.h                     | 4 +---
 libc/src/__support/macros/properties/architectures.h | 6 ++----
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/libc/src/__support/FPUtil/nearest_integer.h b/libc/src/__support/FPUtil/nearest_integer.h
index c13cb1ba3043b3..46e1d9195f14b6 100644
--- a/libc/src/__support/FPUtil/nearest_integer.h
+++ b/libc/src/__support/FPUtil/nearest_integer.h
@@ -14,9 +14,7 @@
 #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_SSE4_2) &&                                     \
-    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
+#if (defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE4_2))
 #include "x86_64/nearest_integer.h"
 #elif (defined(LIBC_TARGET_ARCH_IS_AARCH64) ||                                 \
        defined(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                \
diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h
index e6d656c5a142e2..719c8461248a56 100644
--- a/libc/src/__support/FPUtil/sqrt.h
+++ b/libc/src/__support/FPUtil/sqrt.h
@@ -48,9 +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) &&                                       \
-    defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                     \
-    !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
+#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(LIBC_TARGET_ARCH_IS_ARM64EC)) &&                                \
diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
index 514d1adcfeeb46..90779c99741acd 100644
--- a/libc/src/__support/macros/properties/architectures.h
+++ b/libc/src/__support/macros/properties/architectures.h
@@ -36,10 +36,8 @@
 
 #if defined(__arm64ec__) || defined(_M_ARM64EC)
 #define LIBC_TARGET_ARCH_IS_ARM64EC
-#endif
-
-#if (defined(_M_X64) || defined(__x86_64__)) &&                                \
-    !defined(LIBC_TARGET_ARCH_IS_VM) && !defined(LIBC_TARGET_ARCH_IS_ARM64EC)
+#elif (defined(_M_X64) || defined(__x86_64__)) &&                            \
+    !defined(LIBC_TARGET_ARCH_IS_VM)
 #define LIBC_TARGET_ARCH_IS_X86_64
 #endif
 

>From 8d88f921c01723d67b7e51ec22eda67bdedd248a Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Tue, 6 Oct 2026 10:52:32 -0700
Subject: [PATCH 3/3] Format

---
 libc/src/__support/macros/properties/architectures.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h
index 90779c99741acd..563365102d1740 100644
--- a/libc/src/__support/macros/properties/architectures.h
+++ b/libc/src/__support/macros/properties/architectures.h
@@ -36,7 +36,7 @@
 
 #if defined(__arm64ec__) || defined(_M_ARM64EC)
 #define LIBC_TARGET_ARCH_IS_ARM64EC
-#elif (defined(_M_X64) || defined(__x86_64__)) &&                            \
+#elif (defined(_M_X64) || defined(__x86_64__)) &&                              \
     !defined(LIBC_TARGET_ARCH_IS_VM)
 #define LIBC_TARGET_ARCH_IS_X86_64
 #endif



More information about the libc-commits mailing list