Path: blob/main/contrib/arm-optimized-routines/math/aarch64/sve/hypot.c
48375 views
/*1* Double-precision SVE hypot(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"1011static const struct data12{13uint64_t tiny_bound, thres;14} data = {15.tiny_bound = 0x0c80000000000000, /* asuint (0x1p-102). */16.thres = 0x7300000000000000, /* asuint (inf) - tiny_bound. */17};1819static svfloat64_t NOINLINE20special_case (svfloat64_t sqsum, svfloat64_t x, svfloat64_t y, svbool_t pg,21svbool_t special)22{23return sv_call2_f64 (hypot, x, y, svsqrt_x (pg, sqsum), special);24}2526/* SVE implementation of double-precision hypot.27Maximum error observed is 1.21 ULP:28_ZGVsMxvv_hypot (-0x1.6a22d0412cdd3p+352, 0x1.d3d89bd66fb1ap+330)29got 0x1.6a22d0412cfp+35230want 0x1.6a22d0412cf01p+352. */31svfloat64_t SV_NAME_D2 (hypot) (svfloat64_t x, svfloat64_t y, svbool_t pg)32{33const struct data *d = ptr_barrier (&data);3435svfloat64_t sqsum = svmla_x (pg, svmul_x (pg, x, x), y, y);3637svbool_t special = svcmpge (38pg, svsub_x (pg, svreinterpret_u64 (sqsum), d->tiny_bound), d->thres);3940if (unlikely (svptest_any (pg, special)))41return special_case (sqsum, x, y, pg, special);42return svsqrt_x (pg, sqsum);43}4445TEST_SIG (SV, D, 2, hypot, -10.0, 10.0)46TEST_ULP (SV_NAME_D2 (hypot), 0.71)47TEST_DISABLE_FENV (SV_NAME_D2 (hypot))48TEST_INTERVAL2 (SV_NAME_D2 (hypot), 0, inf, 0, inf, 10000)49TEST_INTERVAL2 (SV_NAME_D2 (hypot), 0, inf, -0, -inf, 10000)50TEST_INTERVAL2 (SV_NAME_D2 (hypot), -0, -inf, 0, inf, 10000)51TEST_INTERVAL2 (SV_NAME_D2 (hypot), -0, -inf, -0, -inf, 10000)52CLOSE_SVE_ATTR535455