Path: blob/main/contrib/arm-optimized-routines/math/aarch64/sve/hypotf.c
48375 views
/*1* Single-precision SVE hypot(x) function.2*3* Copyright (c) 2023-2024, Arm Limited.4* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception5*/67#include "sv_math.h"8#include "test_sig.h"9#include "test_defs.h"1011#define TinyBound 0x0c800000 /* asuint (0x1p-102). */12#define Thres 0x73000000 /* 0x70000000 - TinyBound. */1314static svfloat32_t NOINLINE15special_case (svfloat32_t sqsum, svfloat32_t x, svfloat32_t y, svbool_t pg,16svbool_t special)17{18return sv_call2_f32 (hypotf, x, y, svsqrt_x (pg, sqsum), special);19}2021/* SVE implementation of single-precision hypot.22Maximum error observed is 1.21 ULP:23_ZGVsMxvv_hypotf (0x1.6a213cp-19, -0x1.32b982p-26) got 0x1.6a2346p-1924want 0x1.6a2344p-19. */25svfloat32_t SV_NAME_F2 (hypot) (svfloat32_t x, svfloat32_t y,26const svbool_t pg)27{28svfloat32_t sqsum = svmla_x (pg, svmul_x (pg, x, x), y, y);2930svbool_t special = svcmpge (31pg, svsub_x (pg, svreinterpret_u32 (sqsum), TinyBound), Thres);3233if (unlikely (svptest_any (pg, special)))34return special_case (sqsum, x, y, pg, special);3536return svsqrt_x (pg, sqsum);37}3839TEST_SIG (SV, F, 2, hypot, -10.0, 10.0)40TEST_ULP (SV_NAME_F2 (hypot), 0.71)41TEST_DISABLE_FENV (SV_NAME_F2 (hypot))42TEST_INTERVAL2 (SV_NAME_F2 (hypot), 0, inf, 0, inf, 10000)43TEST_INTERVAL2 (SV_NAME_F2 (hypot), 0, inf, -0, -inf, 10000)44TEST_INTERVAL2 (SV_NAME_F2 (hypot), -0, -inf, 0, inf, 10000)45TEST_INTERVAL2 (SV_NAME_F2 (hypot), -0, -inf, -0, -inf, 10000)46CLOSE_SVE_ATTR474849