Hi all,

This patch adds support for the `fsqrt` instruction on AArch64 platforms in the 
`__FLT_ABI(sqrt)` implementation.

In-lined Patch:

>From aee895b4b7c4045dea64d1206731dc01d29c155c Mon Sep 17 00:00:00 2001
From: Thirumalai Nagalingam <[email protected]>
Date: Wed, 23 Jul 2025 00:37:09 -0700
Subject: [PATCH] Cygwin: math: Add AArch64 support for sqrt()

Extend `__FLT_ABI(sqrt)` implementation to support AArch64 using the
`fsqrt` instruction for double-precision floating point values.
This addition enables square root computation on 64-bit ARM platforms
improving compatibility and performance.

Signed-off-by: Thirumalai Nagalingam 
<[email protected]>
---
 winsup/cygwin/math/sqrt.def.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
index 3d1a00908..598614d3a 100644
--- a/winsup/cygwin/math/sqrt.def.h
+++ b/winsup/cygwin/math/sqrt.def.h
@@ -89,6 +89,8 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
   __fsqrt_internal(x);
 #elif defined(_X86_) || defined(__i386__) || defined(_AMD64_) || 
defined(__x86_64__)
   asm volatile ("fsqrt" : "=t" (res) : "0" (x));
+#elif defined(__aarch64__)
+  asm volatile ("fsqrt %d0, %d1" : "=w"(res) : "w"(x));
 #else
 #error Not supported on your platform yet
 #endif
--
2.49.0.windows.1

Thanks,
Thirumalai Nagalingam


Attachment: 0001-Cygwin-math-Add-AArch64-support-for-sqrt.patch
Description: 0001-Cygwin-math-Add-AArch64-support-for-sqrt.patch

Reply via email to