mirror of git://sourceware.org/git/glibc.git
math: Consolidate acosf and asinf internal tables
The libm size improvement built with gcc-14, "--enable-stack-protector=strong --enable-bind-now=yes --enable-fortify-source=2": Before: 582292 844 12 583148 8e5ec aarch64-linux-gnu/math/libm.so 975133 1076 12 976221 ee55d x86_64-linux-gnu/math/libm.so 1203586 5608 368 1209562 1274da powerpc64le-linux-gnu/math/libm.so After: 581972 844 12 582828 8e4ac aarch64-linux-gnu/math/libm.so 974941 1076 12 976029 ee49d x86_64-linux-gnu/math/libm.so 1203394 5608 368 1209370 12741a powerpc64le-linux-gnu/math/libm.so Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
This commit is contained in:
parent
1faccf388a
commit
0242c9f9e6
|
|
@ -368,6 +368,7 @@ type-float-routines := \
|
||||||
e_powf_log2_data \
|
e_powf_log2_data \
|
||||||
e_sincoshf_data \
|
e_sincoshf_data \
|
||||||
math_errf \
|
math_errf \
|
||||||
|
s_asincosf_data \
|
||||||
s_asincoshf_data \
|
s_asincoshf_data \
|
||||||
s_asincospif_data \
|
s_asincospif_data \
|
||||||
s_sincosf_data \
|
s_sincosf_data \
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ SOFTWARE.
|
||||||
#include <libm-alias-finite.h>
|
#include <libm-alias-finite.h>
|
||||||
#include <math-barriers.h>
|
#include <math-barriers.h>
|
||||||
#include "math_config.h"
|
#include "math_config.h"
|
||||||
|
#include "s_asincosf_data.h"
|
||||||
|
|
||||||
static __attribute__ ((noinline)) float
|
static __attribute__ ((noinline)) float
|
||||||
as_special (float x)
|
as_special (float x)
|
||||||
|
|
@ -110,33 +111,19 @@ __ieee754_acosf (float x)
|
||||||
/* accurate path */
|
/* accurate path */
|
||||||
if (ax < (0x7eu << 24))
|
if (ax < (0x7eu << 24))
|
||||||
{
|
{
|
||||||
static const double c[] =
|
|
||||||
{
|
|
||||||
0x1.555555555529cp-3, 0x1.333333337e0ddp-4, 0x1.6db6db3b4465ep-5,
|
|
||||||
0x1.f1c72e13ac306p-6, 0x1.6e89cebe06bc4p-6, 0x1.1c6dcf5289094p-6,
|
|
||||||
0x1.c6dbbcc7c6315p-7, 0x1.8f8dc2615e996p-7, 0x1.a5833b7bf15e8p-8,
|
|
||||||
0x1.43f44ace1665cp-6, -0x1.0fb17df881c73p-6, 0x1.07520c026b2d6p-5
|
|
||||||
};
|
|
||||||
if (t == 0x328885a3u)
|
if (t == 0x328885a3u)
|
||||||
return 0x1.921fb6p+0f + 0x1p-25;
|
return 0x1.921fb6p+0f + 0x1p-25;
|
||||||
if (t == 0x39826222u)
|
if (t == 0x39826222u)
|
||||||
return 0x1.920f6ap+0f + 0x1p-25;
|
return 0x1.920f6ap+0f + 0x1p-25;
|
||||||
double x2 = xs * xs;
|
double x2 = xs * xs;
|
||||||
r = (pi2 - xs) - (xs * x2) * poly12 (x2, c);
|
r = (pi2 - xs) - (xs * x2) * poly12 (x2, C0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static const double c[] =
|
|
||||||
{
|
|
||||||
0x1.6a09e667f3bcbp+0, 0x1.e2b7dddff2db9p-4, 0x1.b27247ab42dbcp-6,
|
|
||||||
0x1.02995cc4e0744p-7, 0x1.5ffb0276ec8eap-9, 0x1.033885a928decp-10,
|
|
||||||
0x1.911f2be23f8c7p-12, 0x1.4c3c55d2437fdp-13, 0x1.af477e1d7b461p-15,
|
|
||||||
0x1.abd6bdff67dcbp-15, -0x1.1717e86d0fa28p-16, 0x1.6ff526de46023p-16
|
|
||||||
};
|
|
||||||
double bx = fabs (xs);
|
double bx = fabs (xs);
|
||||||
double z = 1.0 - bx;
|
double z = 1.0 - bx;
|
||||||
double s = copysign (sqrt (z), xs);
|
double s = copysign (sqrt (z), xs);
|
||||||
r = o[t >> 31] + s * poly12 (z, c);
|
r = o[t >> 31] + s * poly12 (z, C1);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ SOFTWARE.
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libm-alias-finite.h>
|
#include <libm-alias-finite.h>
|
||||||
#include "math_config.h"
|
#include "math_config.h"
|
||||||
|
#include "s_asincosf_data.h"
|
||||||
|
|
||||||
static __attribute__ ((noinline)) float
|
static __attribute__ ((noinline)) float
|
||||||
as_special (float x)
|
as_special (float x)
|
||||||
|
|
@ -95,16 +96,9 @@ __ieee754_asinf (float x)
|
||||||
}
|
}
|
||||||
if (ax < (0x7eu << 24))
|
if (ax < (0x7eu << 24))
|
||||||
{
|
{
|
||||||
static const double c[] =
|
|
||||||
{
|
|
||||||
0x1.555555555529cp-3, 0x1.333333337e0ddp-4, 0x1.6db6db3b4465ep-5,
|
|
||||||
0x1.f1c72e13ac306p-6, 0x1.6e89cebe06bc4p-6, 0x1.1c6dcf5289094p-6,
|
|
||||||
0x1.c6dbbcc7c6315p-7, 0x1.8f8dc2615e996p-7, 0x1.a5833b7bf15e8p-8,
|
|
||||||
0x1.43f44ace1665cp-6, -0x1.0fb17df881c73p-6, 0x1.07520c026b2d6p-5
|
|
||||||
};
|
|
||||||
double z = xs;
|
double z = xs;
|
||||||
double z2 = z * z;
|
double z2 = z * z;
|
||||||
double c0 = poly12 (z2, c);
|
double c0 = poly12 (z2, C0);
|
||||||
r = z + (z * z2) * c0;
|
r = z + (z * z2) * c0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -116,14 +110,7 @@ __ieee754_asinf (float x)
|
||||||
double bx = fabs (xs);
|
double bx = fabs (xs);
|
||||||
double z = 1.0 - bx;
|
double z = 1.0 - bx;
|
||||||
double s = sqrt (z);
|
double s = sqrt (z);
|
||||||
static const double c[] =
|
r = pi2 - s * poly12 (z, C1);
|
||||||
{
|
|
||||||
0x1.6a09e667f3bcbp+0, 0x1.e2b7dddff2db9p-4, 0x1.b27247ab42dbcp-6,
|
|
||||||
0x1.02995cc4e0744p-7, 0x1.5ffb0276ec8eap-9, 0x1.033885a928decp-10,
|
|
||||||
0x1.911f2be23f8c7p-12, 0x1.4c3c55d2437fdp-13, 0x1.af477e1d7b461p-15,
|
|
||||||
0x1.abd6bdff67dcbp-15, -0x1.1717e86d0fa28p-16, 0x1.6ff526de46023p-16
|
|
||||||
};
|
|
||||||
r = pi2 - s * poly12 (z, c);
|
|
||||||
r = copysign (r, xs);
|
r = copysign (r, xs);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
/* Common data for asinf/acosf implementations.
|
||||||
|
|
||||||
|
Copyright (c) 2023-2024 Alexei Sibidanov.
|
||||||
|
|
||||||
|
The original version of this file was copied from the CORE-MATH
|
||||||
|
project (file src/binary32/asin/asinf.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 "s_asincosf_data.h"
|
||||||
|
|
||||||
|
const double __asincosf_c0[] =
|
||||||
|
{
|
||||||
|
0x1.555555555529cp-3, 0x1.333333337e0ddp-4, 0x1.6db6db3b4465ep-5,
|
||||||
|
0x1.f1c72e13ac306p-6, 0x1.6e89cebe06bc4p-6, 0x1.1c6dcf5289094p-6,
|
||||||
|
0x1.c6dbbcc7c6315p-7, 0x1.8f8dc2615e996p-7, 0x1.a5833b7bf15e8p-8,
|
||||||
|
0x1.43f44ace1665cp-6, -0x1.0fb17df881c73p-6, 0x1.07520c026b2d6p-5
|
||||||
|
};
|
||||||
|
|
||||||
|
const double __asincosf_c1[] =
|
||||||
|
{
|
||||||
|
0x1.6a09e667f3bcbp+0, 0x1.e2b7dddff2db9p-4, 0x1.b27247ab42dbcp-6,
|
||||||
|
0x1.02995cc4e0744p-7, 0x1.5ffb0276ec8eap-9, 0x1.033885a928decp-10,
|
||||||
|
0x1.911f2be23f8c7p-12, 0x1.4c3c55d2437fdp-13, 0x1.af477e1d7b461p-15,
|
||||||
|
0x1.abd6bdff67dcbp-15, -0x1.1717e86d0fa28p-16, 0x1.6ff526de46023p-16
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* Common data for asinf/acosf implementations.
|
||||||
|
|
||||||
|
Copyright (c) 2023-2024 Alexei Sibidanov.
|
||||||
|
|
||||||
|
The original version of this file was copied from the CORE-MATH
|
||||||
|
project (file src/binary32/asin/asinf.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _S_ASINCOSF_DATA_H
|
||||||
|
#define _S_ASINCOSF_DATA_H
|
||||||
|
|
||||||
|
extern const double __asincosf_c0[] attribute_hidden;
|
||||||
|
#define C0 __asincosf_c0
|
||||||
|
extern const double __asincosf_c1[] attribute_hidden;
|
||||||
|
#define C1 __asincosf_c1
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue