Path: blob/main/contrib/arm-optimized-routines/math/aarch64/sve/acosh.c
48375 views
/*1* Double-precision SVE acosh(x) function.2* Copyright (c) 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 WANT_SV_LOG1P_K0_SHORTCUT 111#include "sv_log1p_inline.h"1213#define One (0x3ff0000000000000)14#define Thres (0x1ff0000000000000) /* asuint64 (0x1p511) - One. */1516static svfloat64_t NOINLINE17special_case (svfloat64_t x, svfloat64_t y, svbool_t special)18{19return sv_call_f64 (acosh, x, y, special);20}2122/* SVE approximation for double-precision acosh, based on log1p.23The largest observed error is 3.19 ULP in the region where the24argument to log1p falls in the k=0 interval, i.e. x close to 1:25SV_NAME_D1 (acosh)(0x1.1e4388d4ca821p+0) got 0x1.ed23399f5137p-226want 0x1.ed23399f51373p-2. */27svfloat64_t SV_NAME_D1 (acosh) (svfloat64_t x, const svbool_t pg)28{29/* (ix - One) >= (BigBound - One). */30svuint64_t ix = svreinterpret_u64 (x);31svbool_t special = svcmpge (pg, svsub_x (pg, ix, One), Thres);3233svfloat64_t xm1 = svsub_x (pg, x, 1.0);34svfloat64_t u = svmul_x (pg, xm1, svadd_x (pg, x, 1.0));35svfloat64_t y = svadd_x (pg, xm1, svsqrt_x (pg, u));3637/* Fall back to scalar routine for special lanes. */38if (unlikely (svptest_any (pg, special)))39return special_case (x, sv_log1p_inline (y, pg), special);40return sv_log1p_inline (y, pg);41}4243TEST_SIG (SV, D, 1, acosh, 1.0, 10.0)44TEST_ULP (SV_NAME_D1 (acosh), 2.69)45TEST_DISABLE_FENV (SV_NAME_D1 (acosh))46TEST_INTERVAL (SV_NAME_D1 (acosh), 1, 0x1p511, 90000)47TEST_INTERVAL (SV_NAME_D1 (acosh), 0x1p511, inf, 10000)48TEST_INTERVAL (SV_NAME_D1 (acosh), 0, 1, 1000)49TEST_INTERVAL (SV_NAME_D1 (acosh), -0, -inf, 10000)50CLOSE_SVE_ATTR515253