Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/arm-optimized-routines/math/aarch64/sve/acoshf.c
48375 views
1
/*
2
* Single-precision SVE acosh(x) function.
3
* Copyright (c) 2023-2024, Arm Limited.
4
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
5
*/
6
7
#include "sv_math.h"
8
#include "test_sig.h"
9
#include "test_defs.h"
10
11
#define One 0x3f800000
12
#define Thres 0x20000000 /* asuint(0x1p64) - One. */
13
14
#include "sv_log1pf_inline.h"
15
16
static svfloat32_t NOINLINE
17
special_case (svfloat32_t xm1, svfloat32_t tmp, svbool_t special)
18
{
19
svfloat32_t x = svadd_x (svptrue_b32 (), xm1, 1.0f);
20
svfloat32_t y = sv_log1pf_inline (tmp, svptrue_b32 ());
21
return sv_call_f32 (acoshf, x, y, special);
22
}
23
24
/* Single-precision SVE acosh(x) routine. Implements the same algorithm as
25
vector acoshf and log1p.
26
27
Maximum error is 2.47 ULPs:
28
SV_NAME_F1 (acosh) (0x1.01ca76p+0) got 0x1.e435a6p-4
29
want 0x1.e435a2p-4. */
30
svfloat32_t SV_NAME_F1 (acosh) (svfloat32_t x, const svbool_t pg)
31
{
32
svuint32_t ix = svreinterpret_u32 (x);
33
svbool_t special = svcmpge (pg, svsub_x (pg, ix, One), Thres);
34
35
svfloat32_t xm1 = svsub_x (pg, x, 1.0f);
36
svfloat32_t u = svmul_x (pg, xm1, svadd_x (pg, x, 1.0f));
37
svfloat32_t tmp = svadd_x (pg, xm1, svsqrt_x (pg, u));
38
39
if (unlikely (svptest_any (pg, special)))
40
return special_case (xm1, tmp, special);
41
return sv_log1pf_inline (tmp, pg);
42
}
43
44
TEST_SIG (SV, F, 1, acosh, 1.0, 10.0)
45
TEST_ULP (SV_NAME_F1 (acosh), 1.97)
46
TEST_DISABLE_FENV (SV_NAME_F1 (acosh))
47
TEST_INTERVAL (SV_NAME_F1 (acosh), 0, 1, 500)
48
TEST_INTERVAL (SV_NAME_F1 (acosh), 1, 0x1p64, 100000)
49
TEST_INTERVAL (SV_NAME_F1 (acosh), 0x1p64, inf, 1000)
50
TEST_INTERVAL (SV_NAME_F1 (acosh), -0, -inf, 1000)
51
CLOSE_SVE_ATTR
52
53