Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2b1d38a

Browse files
enh-googleGerrit Code Review
authored andcommitted
Merge "Sync with upstream FreeBSD libm." into main
2 parents 470ac46 + 8cca5d4 commit 2b1d38a

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

libm/upstream-freebsd/lib/msun/src/e_acosf.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ pi = 3.1415925026e+00, /* 0x40490fda */
2222
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
2323
static volatile float
2424
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
25+
26+
/*
27+
* The coefficients for the rational approximation were generated over
28+
* 0x1p-12f <= x <= 0.5f. The maximum error satisfies log2(e) < -30.084.
29+
*/
2530
static const float
26-
pS0 = 1.6666586697e-01,
27-
pS1 = -4.2743422091e-02,
28-
pS2 = -8.6563630030e-03,
29-
qS1 = -7.0662963390e-01;
31+
pS0 = 1.66666672e-01f, /* 0x3e2aaaab */
32+
pS1 = -1.19510300e-01f, /* 0xbdf4c1d1 */
33+
pS2 = 5.47002675e-03f, /* 0x3bb33de9 */
34+
qS1 = -1.16706085e+00f, /* 0xbf956240 */
35+
qS2 = 2.90115148e-01f; /* 0x3e9489f9 */
3036

3137
float
3238
acosf(float x)
@@ -46,13 +52,13 @@ acosf(float x)
4652
if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<2**-26*/
4753
z = x*x;
4854
p = z*(pS0+z*(pS1+z*pS2));
49-
q = one+z*qS1;
55+
q = one+z*(qS1+z*qS2);
5056
r = p/q;
5157
return pio2_hi - (x - (pio2_lo-x*r));
5258
} else if (hx<0) { /* x < -0.5 */
5359
z = (one+x)*(float)0.5;
5460
p = z*(pS0+z*(pS1+z*pS2));
55-
q = one+z*qS1;
61+
q = one+z*(qS1+z*qS2);
5662
s = sqrtf(z);
5763
r = p/q;
5864
w = r*s-pio2_lo;
@@ -66,7 +72,7 @@ acosf(float x)
6672
SET_FLOAT_WORD(df,idf&0xfffff000);
6773
c = (z-df*df)/(s+df);
6874
p = z*(pS0+z*(pS1+z*pS2));
69-
q = one+z*qS1;
75+
q = one+z*(qS1+z*qS2);
7076
r = p/q;
7177
w = r*s+c;
7278
return (float)2.0*(df+w);

libm/upstream-freebsd/lib/msun/src/e_asinf.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818

1919
static const float
2020
one = 1.0000000000e+00, /* 0x3F800000 */
21-
huge = 1.000e+30,
22-
/* coefficient for R(x^2) */
23-
pS0 = 1.6666586697e-01,
24-
pS1 = -4.2743422091e-02,
25-
pS2 = -8.6563630030e-03,
26-
qS1 = -7.0662963390e-01;
21+
huge = 1.000e+30;
22+
23+
/*
24+
* The coefficients for the rational approximation were generated over
25+
* 0x1p-12f <= x <= 0.5f. The maximum error satisfies log2(e) < -30.084.
26+
*/
27+
static const float
28+
pS0 = 1.66666672e-01f, /* 0x3e2aaaab */
29+
pS1 = -1.19510300e-01f, /* 0xbdf4c1d1 */
30+
pS2 = 5.47002675e-03f, /* 0x3bb33de9 */
31+
qS1 = -1.16706085e+00f, /* 0xbf956240 */
32+
qS2 = 2.90115148e-01f; /* 0x3e9489f9 */
2733

2834
static const double
2935
pio2 = 1.570796326794896558e+00;
@@ -46,15 +52,15 @@ asinf(float x)
4652
}
4753
t = x*x;
4854
p = t*(pS0+t*(pS1+t*pS2));
49-
q = one+t*qS1;
55+
q = one+t*(qS1+t*qS2);
5056
w = p/q;
5157
return x+x*w;
5258
}
5359
/* 1> |x|>= 0.5 */
5460
w = one-fabsf(x);
5561
t = w*(float)0.5;
5662
p = t*(pS0+t*(pS1+t*pS2));
57-
q = one+t*qS1;
63+
q = one+t*(qS1+t*qS2);
5864
s = sqrt(t);
5965
w = p/q;
6066
t = pio2-2.0*(s+s*w);

libm/upstream-freebsd/lib/msun/src/math_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ do { \
405405
* any extra precision into the type of 'a' -- 'a' should have type float_t,
406406
* double_t or long double. b's type should be no larger than 'a's type.
407407
* Callers should use these types with scopes as large as possible, to
408-
* reduce their own extra-precision and efficiciency problems. In
408+
* reduce their own extra-precision and efficiency problems. In
409409
* particular, they shouldn't convert back and forth just to call here.
410410
*/
411411
#ifdef DEBUG

libm/upstream-freebsd/lib/msun/src/s_fma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ fma(double x, double y, double z)
260260

261261
spread = ex + ey;
262262

263-
if (r.hi == 0.0) {
263+
if (r.hi == 0.0 && xy.lo == 0) {
264264
/*
265265
* When the addends cancel to 0, ensure that the result has
266266
* the correct sign.
267267
*/
268268
fesetround(oround);
269269
volatile double vzs = zs; /* XXX gcc CSE bug workaround */
270-
return (xy.hi + vzs + ldexp(xy.lo, spread));
270+
return (xy.hi + vzs);
271271
}
272272

273273
if (oround != FE_TONEAREST) {

libm/upstream-freebsd/lib/msun/src/s_fmal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ fmal(long double x, long double y, long double z)
241241

242242
spread = ex + ey;
243243

244-
if (r.hi == 0.0) {
244+
if (r.hi == 0.0 && xy.lo == 0) {
245245
/*
246246
* When the addends cancel to 0, ensure that the result has
247247
* the correct sign.
248248
*/
249249
fesetround(oround);
250250
volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
251-
return (xy.hi + vzs + ldexpl(xy.lo, spread));
251+
return (xy.hi + vzs);
252252
}
253253

254254
if (oround != FE_TONEAREST) {

0 commit comments

Comments
 (0)