2023-06-28 11:19:39 +00:00
|
|
|
/* Single-precision vector (SVE) exp function.
|
|
|
|
|
2024-01-01 18:12:26 +00:00
|
|
|
Copyright (C) 2023-2024 Free Software Foundation, Inc.
|
2023-06-28 11:19:39 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "sv_math.h"
|
2024-09-23 14:26:12 +00:00
|
|
|
#include "sv_expf_inline.h"
|
|
|
|
|
|
|
|
/* Roughly 87.3. For x < -Thres, the result is subnormal and not handled
|
|
|
|
correctly by FEXPA. */
|
|
|
|
#define Thres 0x1.5d5e2ap+6f
|
2023-06-28 11:19:39 +00:00
|
|
|
|
|
|
|
static const struct data
|
|
|
|
{
|
2024-09-23 14:26:12 +00:00
|
|
|
struct sv_expf_data d;
|
|
|
|
float thres;
|
2023-06-28 11:19:39 +00:00
|
|
|
} data = {
|
2024-09-23 14:26:12 +00:00
|
|
|
.d = SV_EXPF_DATA,
|
|
|
|
.thres = Thres,
|
2023-06-28 11:19:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static svfloat32_t NOINLINE
|
2024-09-23 14:26:12 +00:00
|
|
|
special_case (svfloat32_t x, svbool_t special, const struct sv_expf_data *d)
|
2023-06-28 11:19:39 +00:00
|
|
|
{
|
2024-09-23 14:26:12 +00:00
|
|
|
return sv_call_f32 (expf, x, expf_inline (x, svptrue_b32 (), d), special);
|
2023-06-28 11:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Optimised single-precision SVE exp function.
|
|
|
|
Worst-case error is 1.04 ulp:
|
|
|
|
SV_NAME_F1 (exp)(0x1.a8eda4p+1) got 0x1.ba74bcp+4
|
|
|
|
want 0x1.ba74bap+4. */
|
|
|
|
svfloat32_t SV_NAME_F1 (exp) (svfloat32_t x, const svbool_t pg)
|
|
|
|
{
|
|
|
|
const struct data *d = ptr_barrier (&data);
|
2023-10-04 09:40:04 +00:00
|
|
|
svbool_t is_special_case = svacgt (pg, x, d->thres);
|
2023-06-28 11:19:39 +00:00
|
|
|
if (__glibc_unlikely (svptest_any (pg, is_special_case)))
|
2024-09-23 14:26:12 +00:00
|
|
|
return special_case (x, is_special_case, &d->d);
|
|
|
|
return expf_inline (x, pg, &d->d);
|
2023-06-28 11:19:39 +00:00
|
|
|
}
|