[3/3] AArch64: Add tests for __sqrt and __sqrtf intrinsic

Message ID Z9DSgrzNiPNAY6dZ@sawtooth
State New
Headers
Series [1/3] AArch64: Use BUILTIN_VHSDF_HSDF for vector and scalar sqrt builtins |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap success Build passed

Commit Message

Ayan Shafqat March 12, 2025, 12:17 a.m. UTC
  This patch introduces acle_sqrt.c in the AArch64 testsuite, verifying
that the new __sqrt and __sqrtf intrinsics emit the expected fsqrt
instructions for double and float arguments.

Coverage for new intrinsics ensures that __sqrt and __sqrtf are
correctly expanded to hardware instructions and do not fall back to
library calls, regardless of optimization levels.

Signed-off-by: Ayan Shafqat <ayan.x.shafqat@gmail.com>
---
 .../gcc.target/aarch64/acle/acle_sqrt.c         | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/acle_sqrt.c
  

Patch

diff --git a/gcc/testsuite/gcc.target/aarch64/acle/acle_sqrt.c b/gcc/testsuite/gcc.target/aarch64/acle/acle_sqrt.c
new file mode 100644
index 00000000000..1e3ed9eaa6d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/acle/acle_sqrt.c
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include "arm_acle.h"
+
+double test_acle_sqrt (double x)
+{
+  return __sqrt (x);
+}
+
+float test_acle_sqrtf (float x)
+{
+  return __sqrtf (x);
+}
+
+/* { dg-final { scan-assembler-times "fsqrt\td\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "fsqrt\ts\[0-9\]" 1 } } */