Path: blob/main/contrib/arm-optimized-routines/math/aarch64/sve/acoshf.c
48375 views
/*1* Single-precision SVE acosh(x) function.2* Copyright (c) 2023-2024, Arm Limited.3* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception4*/56#include "sv_math.h"7#include "test_sig.h"8#include "test_defs.h"910#define One 0x3f80000011#define Thres 0x20000000 /* asuint(0x1p64) - One. */1213#include "sv_log1pf_inline.h"1415static svfloat32_t NOINLINE16special_case (svfloat32_t xm1, svfloat32_t tmp, svbool_t special)17{18svfloat32_t x = svadd_x (svptrue_b32 (), xm1, 1.0f);19svfloat32_t y = sv_log1pf_inline (tmp, svptrue_b32 ());20return sv_call_f32 (acoshf, x, y, special);21}2223/* Single-precision SVE acosh(x) routine. Implements the same algorithm as24vector acoshf and log1p.2526Maximum error is 2.47 ULPs:27SV_NAME_F1 (acosh) (0x1.01ca76p+0) got 0x1.e435a6p-428want 0x1.e435a2p-4. */29svfloat32_t SV_NAME_F1 (acosh) (svfloat32_t x, const svbool_t pg)30{31svuint32_t ix = svreinterpret_u32 (x);32svbool_t special = svcmpge (pg, svsub_x (pg, ix, One), Thres);3334svfloat32_t xm1 = svsub_x (pg, x, 1.0f);35svfloat32_t u = svmul_x (pg, xm1, svadd_x (pg, x, 1.0f));36svfloat32_t tmp = svadd_x (pg, xm1, svsqrt_x (pg, u));3738if (unlikely (svptest_any (pg, special)))39return special_case (xm1, tmp, special);40return sv_log1pf_inline (tmp, pg);41}4243TEST_SIG (SV, F, 1, acosh, 1.0, 10.0)44TEST_ULP (SV_NAME_F1 (acosh), 1.97)45TEST_DISABLE_FENV (SV_NAME_F1 (acosh))46TEST_INTERVAL (SV_NAME_F1 (acosh), 0, 1, 500)47TEST_INTERVAL (SV_NAME_F1 (acosh), 1, 0x1p64, 100000)48TEST_INTERVAL (SV_NAME_F1 (acosh), 0x1p64, inf, 1000)49TEST_INTERVAL (SV_NAME_F1 (acosh), -0, -inf, 1000)50CLOSE_SVE_ATTR515253