mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
math: Use log1pf from CORE-MATH
The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows slight better performance to the generic log1pf. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (M1, gcc 13.2.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 71.8142 38.9668 45.74% x86_64v2 71.9094 39.1321 45.58% x86_64v3 60.1000 32.4016 46.09% i686 147.105 104.258 29.13% aarch64 26.4439 14.0050 47.04% power10 19.4874 9.4146 51.69% powerpc 17.6145 8.00736 54.54% reciprocal-throughput master patched improvement x86_64 19.7604 12.7254 35.60% x86_64v2 19.0039 11.9455 37.14% x86_64v3 16.8559 11.9317 29.21% i686 82.3426 73.9718 10.17% aarch64 14.4665 7.9614 44.97% power10 11.9974 8.4117 29.89% powerpc 7.15222 6.0914 14.83% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
parent
c369580814
commit
8ae9e51376
@ -260,3 +260,7 @@ sysdeps/ieee754/flt-32/s_log2p1f.c
|
||||
(file src/binary32/log2p1/log2p1f.c in CORE-MATH)
|
||||
- The code was adapted to use glibc code style and internal
|
||||
functions to handle errno, overflow, and underflow.
|
||||
sysdeps/ieee754/flt-32/s_log1pf.c
|
||||
(file src/binary32/log1p/log1pf.c in CORE-MATH)
|
||||
- The code was adapted to use glibc code style and internal
|
||||
functions to handle errno, overflow, and underflow.
|
||||
|
@ -1366,7 +1366,6 @@ ldouble: 4
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_advsimd":
|
||||
@ -1375,7 +1374,6 @@ float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_sve":
|
||||
@ -1384,12 +1382,10 @@ float: 1
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1459,22 +1455,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -1202,22 +1202,18 @@ ldouble: 3
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1267,22 +1263,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -981,19 +981,15 @@ float: 3
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -1029,19 +1025,15 @@ float: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -238,7 +238,6 @@ float: 2
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
|
@ -974,19 +974,15 @@ float: 3
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -1028,19 +1024,15 @@ float: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -919,19 +919,15 @@ float: 2
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -948,19 +944,15 @@ double: 3
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -920,19 +920,15 @@ float: 2
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -962,19 +958,15 @@ float: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -997,19 +997,15 @@ float: 3
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -1051,19 +1047,15 @@ float: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -1443,19 +1443,16 @@ ldouble: 2
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
@ -1524,19 +1521,16 @@ ldouble: 2
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <i386-math-asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_log1pf.S,v 1.4 1995/05/09 00:13:05 jtc Exp $")
|
||||
|
||||
.section .rodata
|
||||
|
||||
.align ALIGNARG(4)
|
||||
/* The fyl2xp1 can only be used for values in
|
||||
-1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2
|
||||
0.29 is a safe value.
|
||||
*/
|
||||
limit: .float 0.29
|
||||
one: .float 1.0
|
||||
|
||||
DEFINE_FLT_MIN
|
||||
|
||||
#ifdef PIC
|
||||
# define MO(op) op##@GOTOFF(%edx)
|
||||
#else
|
||||
# define MO(op) op
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29,
|
||||
* otherwise fyl2x with the needed extra computation.
|
||||
*/
|
||||
.text
|
||||
ENTRY(__log1pf)
|
||||
fldln2
|
||||
|
||||
flds 4(%esp)
|
||||
|
||||
#ifdef PIC
|
||||
LOAD_PIC_REG (dx)
|
||||
#endif
|
||||
|
||||
fxam
|
||||
fnstsw
|
||||
fld %st
|
||||
sahf
|
||||
jc 3f // in case x is NaN or ±Inf
|
||||
4: fabs
|
||||
fcomps MO(limit)
|
||||
fnstsw
|
||||
sahf
|
||||
jc 2f
|
||||
|
||||
fadds MO(one)
|
||||
fyl2x
|
||||
ret
|
||||
|
||||
2: fyl2xp1
|
||||
FLT_CHECK_FORCE_UFLOW_NONNAN
|
||||
ret
|
||||
|
||||
3: jp 4b // in case x is ±Inf
|
||||
fstp %st(1)
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
END (__log1pf)
|
@ -1446,19 +1446,16 @@ ldouble: 2
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
@ -1527,19 +1524,16 @@ ldouble: 2
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
|
@ -1,116 +1,181 @@
|
||||
/* s_log1pf.c -- float version of s_log1p.c.
|
||||
*/
|
||||
/* Correctly-rounded biased argument natural logarithm function for binary32
|
||||
value.
|
||||
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
Copyright (c) 2023, 2024 Alexei Sibidanov.
|
||||
|
||||
This file is part of the CORE-MATH project
|
||||
project (file src/binary32/log1p/log1pf.c revision bc385c2).
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <math-barriers.h>
|
||||
#include <math_private.h>
|
||||
#include <math-underflow.h>
|
||||
#include <libc-diag.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include "math_config.h"
|
||||
|
||||
static const float
|
||||
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
|
||||
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
|
||||
two25 = 3.355443200e+07, /* 0x4c000000 */
|
||||
Lp1 = 6.6666668653e-01, /* 3F2AAAAB */
|
||||
Lp2 = 4.0000000596e-01, /* 3ECCCCCD */
|
||||
Lp3 = 2.8571429849e-01, /* 3E924925 */
|
||||
Lp4 = 2.2222198546e-01, /* 3E638E29 */
|
||||
Lp5 = 1.8183572590e-01, /* 3E3A3325 */
|
||||
Lp6 = 1.5313838422e-01, /* 3E1CD04F */
|
||||
Lp7 = 1.4798198640e-01; /* 3E178897 */
|
||||
|
||||
static const float zero = 0.0;
|
||||
static __attribute__ ((noinline)) float
|
||||
as_special (float x)
|
||||
{
|
||||
uint32_t t = asuint (x);
|
||||
if (t == 0xbf800000u)
|
||||
return __math_divzerof (1);
|
||||
if (t == 0x7f800000u)
|
||||
return x; /* +inf */
|
||||
uint32_t ax = t << 1;
|
||||
if (ax > 0xff000000u)
|
||||
return x + x; /* nan */
|
||||
return __math_invalidf (0.0f);
|
||||
}
|
||||
|
||||
float
|
||||
__log1pf(float x)
|
||||
__log1pf (float x)
|
||||
{
|
||||
float hfsq,f,c,s,z,R,u;
|
||||
int32_t k,hx,hu,ax;
|
||||
static const double x0[] =
|
||||
{
|
||||
0x1.f81f82p-1, 0x1.e9131acp-1, 0x1.dae6077p-1, 0x1.cd85689p-1,
|
||||
0x1.c0e0704p-1, 0x1.b4e81b5p-1, 0x1.a98ef6p-1, 0x1.9ec8e95p-1,
|
||||
0x1.948b0fdp-1, 0x1.8acb90fp-1, 0x1.8181818p-1, 0x1.78a4c81p-1,
|
||||
0x1.702e05cp-1, 0x1.6816817p-1, 0x1.605816p-1, 0x1.58ed231p-1,
|
||||
0x1.51d07ebp-1, 0x1.4afd6ap-1, 0x1.446f865p-1, 0x1.3e22cbdp-1,
|
||||
0x1.3813814p-1, 0x1.323e34ap-1, 0x1.2c9fb4ep-1, 0x1.27350b9p-1,
|
||||
0x1.21fb781p-1, 0x1.1cf06aep-1, 0x1.1811812p-1, 0x1.135c811p-1,
|
||||
0x1.0ecf56cp-1, 0x1.0a6810ap-1, 0x1.0624dd3p-1, 0x1.0204081p-1
|
||||
};
|
||||
static const double lixb[] =
|
||||
{
|
||||
0x1.fc0a8909b4218p-7, 0x1.77458f51aac89p-5, 0x1.341d793afb997p-4,
|
||||
0x1.a926d3a5ebd2ap-4, 0x1.0d77e7a8a823dp-3, 0x1.44d2b6c557102p-3,
|
||||
0x1.7ab89040accecp-3, 0x1.af3c94ecab3d6p-3, 0x1.e27076d54e6c9p-3,
|
||||
0x1.0a324e3888ad5p-2, 0x1.22941fc0c7357p-2, 0x1.3a64c56ae3fdbp-2,
|
||||
0x1.51aad874af21fp-2, 0x1.686c81d300eap-2, 0x1.7eaf83c7fa9b5p-2,
|
||||
0x1.947941aa610ecp-2, 0x1.a9cec9a3f023bp-2, 0x1.beb4d9ea4156ep-2,
|
||||
0x1.d32fe7f35e5c7p-2, 0x1.e7442617b817ap-2, 0x1.faf588dd5ed1p-2,
|
||||
0x1.0723e5c635c39p-1, 0x1.109f39d53c99p-1, 0x1.19ee6b38a4668p-1,
|
||||
0x1.23130d7f93c3bp-1, 0x1.2c0e9ec9b0b85p-1, 0x1.34e289cb35eccp-1,
|
||||
0x1.3d9026ad3d3f3p-1, 0x1.4618bc1eadbbbp-1, 0x1.4e7d8127dd8a9p-1,
|
||||
0x1.56bf9d5967092p-1, 0x1.5ee02a926936ep-1
|
||||
};
|
||||
static const double lix[] =
|
||||
{
|
||||
0x1.fc0a890fc03e4p-7, 0x1.77458f532dcfcp-5, 0x1.341d793bbd1d1p-4,
|
||||
0x1.a926d3a6ad563p-4, 0x1.0d77e7a908e59p-3, 0x1.44d2b6c5b7d1ep-3,
|
||||
0x1.7ab890410d909p-3, 0x1.af3c94ed0bff3p-3, 0x1.e27076d5af2e6p-3,
|
||||
0x1.0a324e38b90e3p-2, 0x1.22941fc0f7966p-2, 0x1.3a64c56b145eap-2,
|
||||
0x1.51aad874df82dp-2, 0x1.686c81d3314afp-2, 0x1.7eaf83c82afc3p-2,
|
||||
0x1.947941aa916fbp-2, 0x1.a9cec9a42084ap-2, 0x1.beb4d9ea71b7cp-2,
|
||||
0x1.d32fe7f38ebd5p-2, 0x1.e7442617e8788p-2, 0x1.faf588dd8f31fp-2,
|
||||
0x1.0723e5c64df4p-1, 0x1.109f39d554c97p-1, 0x1.19ee6b38bc96fp-1,
|
||||
0x1.23130d7fabf43p-1, 0x1.2c0e9ec9c8e8cp-1, 0x1.34e289cb4e1d3p-1,
|
||||
0x1.3d9026ad556fbp-1, 0x1.4618bc1ec5ec2p-1, 0x1.4e7d8127f5bb1p-1,
|
||||
0x1.56bf9d597f399p-1, 0x1.5ee02a9281675p-1
|
||||
};
|
||||
static const double b[] =
|
||||
{
|
||||
0x1p+0,
|
||||
-0x1p-1,
|
||||
0x1.5555555556f6bp-2,
|
||||
-0x1.00000000029b9p-2,
|
||||
0x1.9999988d176e4p-3,
|
||||
-0x1.55555418889a7p-3,
|
||||
0x1.24adeca50e2bcp-3,
|
||||
-0x1.001ba33bf57cfp-3
|
||||
};
|
||||
|
||||
GET_FLOAT_WORD(hx,x);
|
||||
ax = hx&0x7fffffff;
|
||||
|
||||
k = 1;
|
||||
if (hx < 0x3ed413d7) { /* x < 0.41422 */
|
||||
if(ax>=0x3f800000) { /* x <= -1.0 */
|
||||
if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=-inf */
|
||||
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
|
||||
}
|
||||
if(ax<0x31000000) { /* |x| < 2**-29 */
|
||||
math_force_eval(two25+x); /* raise inexact */
|
||||
if (ax<0x24800000) /* |x| < 2**-54 */
|
||||
{
|
||||
math_check_force_underflow (x);
|
||||
return x;
|
||||
}
|
||||
else
|
||||
return x - x*x*(float)0.5;
|
||||
}
|
||||
if(hx>0||hx<=((int32_t)0xbe95f61f)) {
|
||||
k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */
|
||||
double z = x;
|
||||
uint32_t ux = asuint (x);
|
||||
uint32_t ax = ux & (~0u >> 1);
|
||||
if (__glibc_likely (ax < 0x3c880000))
|
||||
{
|
||||
if (__glibc_unlikely (ax < 0x33000000))
|
||||
{
|
||||
if (!ax)
|
||||
return x;
|
||||
return fmaf (x, -x, x);
|
||||
}
|
||||
if (hx >= 0x7f800000) return x+x;
|
||||
if(k!=0) {
|
||||
if(hx<0x5a000000) {
|
||||
u = (float)1.0+x;
|
||||
GET_FLOAT_WORD(hu,u);
|
||||
k = (hu>>23)-127;
|
||||
/* correction term */
|
||||
c = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0);
|
||||
c /= u;
|
||||
} else {
|
||||
u = x;
|
||||
GET_FLOAT_WORD(hu,u);
|
||||
k = (hu>>23)-127;
|
||||
c = 0;
|
||||
double z2 = z * z, z4 = z2 * z2;
|
||||
double f = z2
|
||||
* ((b[1] + z * b[2]) + z2 * (b[3] + z * b[4])
|
||||
+ z4 * ((b[5] + z * b[6]) + z2 * b[7]));
|
||||
double r = z + f;
|
||||
if (__glibc_unlikely ((asuint64 (r) & 0xfffffffll) == 0))
|
||||
r += 0x1p14 * (f + (z - r));
|
||||
return r;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__glibc_unlikely (ux >= 0xbf800000u || ax >= 0x7f800000))
|
||||
return as_special (x);
|
||||
uint64_t tp = asuint64 (z + 1);
|
||||
int e = tp >> 52;
|
||||
uint64_t m52 = tp & (~(uint64_t) 0 >> 12);
|
||||
unsigned int j = (tp >> (52 - 5)) & 31;
|
||||
e -= 0x3ff;
|
||||
double xd = asdouble (m52 | ((uint64_t) 0x3ff << 52));
|
||||
z = xd * x0[j] - 1;
|
||||
static const double c[] =
|
||||
{
|
||||
-0x1.3902c33434e7fp-43, 0x1.ffffffe1cbed5p-1, -0x1.ffffff7d1b014p-2,
|
||||
0x1.5564e0ed3613ap-2, -0x1.0012232a00d4ap-2
|
||||
};
|
||||
const double ln2 = 0x1.62e42fefa39efp-1;
|
||||
double z2 = z * z,
|
||||
r = (ln2 * e + lixb[j])
|
||||
+ z * ((c[1] + z * c[2]) + z2 * (c[3] + z * c[4]));
|
||||
float ub = r;
|
||||
float lb = r + 2.2e-11;
|
||||
if (__glibc_unlikely (ub != lb))
|
||||
{
|
||||
double z4 = z2 * z2,
|
||||
f = z
|
||||
* ((b[0] + z * b[1]) + z2 * (b[2] + z * b[3])
|
||||
+ z4 * ((b[4] + z * b[5]) + z2 * (b[6] + z * b[7])));
|
||||
const double ln2l = 0x1.7f7d1cf79abcap-20, ln2h = 0x1.62e4p-1;
|
||||
double Lh = ln2h * e;
|
||||
double Ll = ln2l * e;
|
||||
double rl = f + Ll + lix[j];
|
||||
double tr = rl + Lh;
|
||||
if (__glibc_unlikely ((asuint64 (tr) & 0xfffffffll) == 0))
|
||||
{
|
||||
if (x == -0x1.247ab0p-6)
|
||||
return -0x1.271f0ep-6f - 0x1p-31f;
|
||||
if (x == -0x1.3a415ep-5)
|
||||
return -0x1.407112p-5f + 0x1p-30f;
|
||||
if (x == 0x1.fb035ap-2)
|
||||
return 0x1.9bddc2p-2f + 0x1p-27f;
|
||||
tr += 64 * (rl + (Lh - tr));
|
||||
}
|
||||
hu &= 0x007fffff;
|
||||
if(hu<0x3504f7) {
|
||||
SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */
|
||||
} else {
|
||||
k += 1;
|
||||
SET_FLOAT_WORD(u,hu|0x3f000000); /* normalize u/2 */
|
||||
hu = (0x00800000-hu)>>2;
|
||||
else if (rl + (Lh - tr) == 0.0)
|
||||
{
|
||||
if (x == 0x1.b7fd86p-4)
|
||||
return 0x1.a1ece2p-4f + 0x1p-29f;
|
||||
if (x == -0x1.3a415ep-5)
|
||||
return -0x1.407112p-5f + 0x1p-30f;
|
||||
if (x == 0x1.43c7e2p-6)
|
||||
return 0x1.409f80p-6f + 0x1p-31f;
|
||||
}
|
||||
f = u-(float)1.0;
|
||||
ub = tr;
|
||||
}
|
||||
hfsq=(float)0.5*f*f;
|
||||
if(hu==0) { /* |f| < 2**-20 */
|
||||
if(f==zero) {
|
||||
if(k==0) return zero;
|
||||
else {c += k*ln2_lo; return k*ln2_hi+c;}
|
||||
}
|
||||
R = hfsq*(1.0f-0.66666666666666666f*f);
|
||||
if(k==0) return f-R; else
|
||||
return k*ln2_hi-((R-(k*ln2_lo+c))-f);
|
||||
}
|
||||
s = f/((float)2.0+f);
|
||||
z = s*s;
|
||||
R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
|
||||
if (k == 0)
|
||||
return f - (hfsq - s * (hfsq + R));
|
||||
else
|
||||
{
|
||||
/* With GCC 7 when compiling with -Os the compiler warns
|
||||
that c might be used uninitialized. This can't be true
|
||||
because k must be 0 for c to be uninitialized and we
|
||||
handled that computation earlier without using c. */
|
||||
DIAG_PUSH_NEEDS_COMMENT;
|
||||
DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized");
|
||||
return k * ln2_hi - ((hfsq - (s * (hfsq + R)
|
||||
+ (k * ln2_lo + c))) - f);
|
||||
DIAG_POP_NEEDS_COMMENT;
|
||||
}
|
||||
return ub;
|
||||
}
|
||||
}
|
||||
libm_alias_float (__log1p, log1p)
|
||||
strong_alias (__log1pf, __logp1f)
|
||||
libm_alias_float (__logp1, logp1)
|
||||
|
1
sysdeps/ieee754/flt-32/w_log1pf.c
Normal file
1
sysdeps/ieee754/flt-32/w_log1pf.c
Normal file
@ -0,0 +1 @@
|
||||
/* Not needed. */
|
@ -1215,22 +1215,18 @@ ldouble: 4
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1278,22 +1274,18 @@ ldouble: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -131,12 +131,6 @@ Function: "log10":
|
||||
double: 1
|
||||
float: 2
|
||||
|
||||
Function: "log1p":
|
||||
float: 1
|
||||
|
||||
Function: "logp1":
|
||||
float: 1
|
||||
|
||||
Function: "sincos":
|
||||
double: 1
|
||||
float: 1
|
||||
|
20
sysdeps/m68k/m680x0/fpu/w_log1pf.c
Normal file
20
sysdeps/m68k/m680x0/fpu/w_log1pf.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* Wrapper for __log1p that handles setting errno.
|
||||
Copyright (C) 2015-2024 Free Software Foundation, Inc.
|
||||
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 <math-type-macros-float.h>
|
||||
#include <w_log1p_template.c>
|
@ -224,7 +224,6 @@ float: 2
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -232,7 +231,6 @@ float: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "pow":
|
||||
float: 1
|
||||
|
@ -971,19 +971,15 @@ float: 3
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -1029,19 +1025,15 @@ float: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -1220,22 +1220,18 @@ ldouble: 4
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1289,22 +1285,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -230,7 +230,6 @@ float: 2
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -238,7 +237,6 @@ float: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -923,19 +923,15 @@ float: 2
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
float: 1
|
||||
@ -951,19 +947,15 @@ double: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -1521,25 +1521,21 @@ ldouble: 6
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 2
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
@ -1605,25 +1601,21 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 2
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
|
@ -1277,22 +1277,18 @@ ldouble: 6
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 2
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1346,22 +1342,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 2
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "mul_downward_ldouble":
|
||||
|
@ -1172,22 +1172,18 @@ ldouble: 3
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1223,22 +1219,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -1215,22 +1215,18 @@ ldouble: 4
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1278,22 +1274,18 @@ ldouble: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -1216,22 +1216,18 @@ ldouble: 4
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1276,22 +1272,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 1
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -460,11 +460,9 @@ float: 1
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "log2":
|
||||
double: 2
|
||||
@ -475,11 +473,9 @@ double: 2
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
|
||||
Function: "pow":
|
||||
double: 1
|
||||
|
@ -1220,22 +1220,18 @@ ldouble: 4
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "log2":
|
||||
@ -1289,22 +1285,18 @@ ldouble: 1
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 3
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
ldouble: 2
|
||||
|
||||
Function: "pow":
|
||||
|
@ -1822,25 +1822,21 @@ ldouble: 6
|
||||
|
||||
Function: "log1p":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 2
|
||||
|
||||
Function: "log1p_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "log1p_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "log1p_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
@ -1966,25 +1962,21 @@ float: 3
|
||||
|
||||
Function: "logp1":
|
||||
double: 1
|
||||
float: 1
|
||||
float128: 3
|
||||
ldouble: 2
|
||||
|
||||
Function: "logp1_downward":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "logp1_towardzero":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 3
|
||||
ldouble: 4
|
||||
|
||||
Function: "logp1_upward":
|
||||
double: 2
|
||||
float: 2
|
||||
float128: 2
|
||||
ldouble: 3
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user