Path: blob/main/contrib/arm-optimized-routines/math/aarch64/advsimd/acosh.c
48375 views
/*1* Double-precision vector acosh(x) function.2* Copyright (c) 2023-2024, Arm Limited.3* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception4*/56#include "v_math.h"7#include "test_sig.h"8#include "test_defs.h"910#define WANT_V_LOG1P_K0_SHORTCUT 111#include "v_log1p_inline.h"1213const static struct data14{15struct v_log1p_data log1p_consts;16uint64x2_t one, thresh;17} data = {18.log1p_consts = V_LOG1P_CONSTANTS_TABLE,19.one = V2 (0x3ff0000000000000),20.thresh = V2 (0x1ff0000000000000) /* asuint64(0x1p511) - asuint64(1). */21};2223static float64x2_t NOINLINE VPCS_ATTR24special_case (float64x2_t x, float64x2_t y, uint64x2_t special,25const struct v_log1p_data *d)26{27return v_call_f64 (acosh, x, log1p_inline (y, d), special);28}2930/* Vector approximation for double-precision acosh, based on log1p.31The largest observed error is 3.02 ULP in the region where the32argument to log1p falls in the k=0 interval, i.e. x close to 1:33_ZGVnN2v_acosh(0x1.00798aaf80739p+0) got 0x1.f2d6d823bc9dfp-534want 0x1.f2d6d823bc9e2p-5. */35VPCS_ATTR float64x2_t V_NAME_D1 (acosh) (float64x2_t x)36{37const struct data *d = ptr_barrier (&data);38uint64x2_t special39= vcgeq_u64 (vsubq_u64 (vreinterpretq_u64_f64 (x), d->one), d->thresh);40float64x2_t special_arg = x;4142#if WANT_SIMD_EXCEPT43if (unlikely (v_any_u64 (special)))44x = vbslq_f64 (special, vreinterpretq_f64_u64 (d->one), x);45#endif4647float64x2_t xm1 = vsubq_f64 (x, v_f64 (1.0));48float64x2_t y = vaddq_f64 (x, v_f64 (1.0));49y = vmulq_f64 (y, xm1);50y = vsqrtq_f64 (y);51y = vaddq_f64 (xm1, y);5253if (unlikely (v_any_u64 (special)))54return special_case (special_arg, y, special, &d->log1p_consts);55return log1p_inline (y, &d->log1p_consts);56}5758TEST_SIG (V, D, 1, acosh, 1.0, 10.0)59TEST_ULP (V_NAME_D1 (acosh), 2.53)60TEST_DISABLE_FENV_IF_NOT (V_NAME_D1 (acosh), WANT_SIMD_EXCEPT)61TEST_INTERVAL (V_NAME_D1 (acosh), 1, 0x1p511, 90000)62TEST_INTERVAL (V_NAME_D1 (acosh), 0x1p511, inf, 10000)63TEST_INTERVAL (V_NAME_D1 (acosh), 0, 1, 1000)64TEST_INTERVAL (V_NAME_D1 (acosh), -0, -inf, 10000)656667