Path: blob/main/contrib/arm-optimized-routines/math/aarch64/sve/asinhf.c
48375 views
/*1* Single-precision SVE asinh(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#include "sv_log1pf_inline.h"1213#define BigBound 0x5f800000 /* asuint(0x1p64). */1415static svfloat32_t NOINLINE16special_case (svuint32_t iax, svuint32_t sign, svfloat32_t y, svbool_t special)17{18svfloat32_t x = svreinterpret_f32 (sveor_x (svptrue_b32 (), iax, sign));19y = svreinterpret_f32 (20svorr_x (svptrue_b32 (), sign, svreinterpret_u32 (y)));21return sv_call_f32 (asinhf, x, y, special);22}2324/* Single-precision SVE asinh(x) routine. Implements the same algorithm as25vector asinhf and log1p.2627Maximum error is 1.92 ULPs:28SV_NAME_F1 (asinh) (-0x1.0922ecp-1) got -0x1.fd0bccp-229want -0x1.fd0bc8p-2. */30svfloat32_t SV_NAME_F1 (asinh) (svfloat32_t x, const svbool_t pg)31{32svfloat32_t ax = svabs_x (pg, x);33svuint32_t iax = svreinterpret_u32 (ax);34svuint32_t sign = sveor_x (pg, svreinterpret_u32 (x), iax);35svbool_t special = svcmpge (pg, iax, BigBound);3637/* asinh(x) = log(x + sqrt(x * x + 1)).38For positive x, asinh(x) = log1p(x + x * x / (1 + sqrt(x * x + 1))). */39svfloat32_t ax2 = svmul_x (pg, ax, ax);40svfloat32_t d = svadd_x (pg, svsqrt_x (pg, svadd_x (pg, ax2, 1.0f)), 1.0f);41svfloat32_t y42= sv_log1pf_inline (svadd_x (pg, ax, svdiv_x (pg, ax2, d)), pg);4344if (unlikely (svptest_any (pg, special)))45return special_case (iax, sign, y, special);46return svreinterpret_f32 (svorr_x (pg, sign, svreinterpret_u32 (y)));47}4849TEST_SIG (SV, F, 1, asinh, -10.0, 10.0)50TEST_ULP (SV_NAME_F1 (asinh), 1.43)51TEST_DISABLE_FENV (SV_NAME_F1 (asinh))52TEST_SYM_INTERVAL (SV_NAME_F1 (asinh), 0, 0x1p-12, 4000)53TEST_SYM_INTERVAL (SV_NAME_F1 (asinh), 0x1p-12, 1.0, 20000)54TEST_SYM_INTERVAL (SV_NAME_F1 (asinh), 1.0, 0x1p64, 20000)55TEST_SYM_INTERVAL (SV_NAME_F1 (asinh), 0x1p64, inf, 4000)56CLOSE_SVE_ATTR575859