Sync libm with upstream FreeBSD.
Upstream SHA 78599c32efed3247d165302a1fbe8d9203e38974.
Test: treehugger
Change-Id: Ib103d211315e320df89a6f0bcb30cd8ba67dd603
diff --git a/libm/upstream-freebsd/lib/msun/ld128/e_powl.c b/libm/upstream-freebsd/lib/msun/ld128/e_powl.c
index 2f3ee55..12b92a1 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/e_powl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/e_powl.c
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/e_powl.c 342651 2018-12-31 15:43:06Z pfg $");
+__FBSDID("$FreeBSD$");
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h b/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h
index 1ed79ae..fcef399 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h
@@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/e_rem_pio2l.h 336545 2018-07-20 12:42:24Z bde $");
+__FBSDID("$FreeBSD$");
/* ld128 version of __ieee754_rem_pio2l(x,y)
*
diff --git a/libm/upstream-freebsd/lib/msun/ld128/invtrig.c b/libm/upstream-freebsd/lib/msun/ld128/invtrig.c
index e89a226..ab93732 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/invtrig.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/invtrig.c
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/invtrig.c 326219 2017-11-26 02:00:33Z pfg $");
+__FBSDID("$FreeBSD$");
#include "invtrig.h"
diff --git a/libm/upstream-freebsd/lib/msun/ld128/invtrig.h b/libm/upstream-freebsd/lib/msun/ld128/invtrig.h
index fd1302a..423b568 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/invtrig.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/invtrig.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/lib/msun/ld128/invtrig.h 326219 2017-11-26 02:00:33Z pfg $
+ * $FreeBSD$
*/
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/ld128/k_expl.h b/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
index b80d00e..159338f 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/k_expl.h 336545 2018-07-20 12:42:24Z bde $");
+__FBSDID("$FreeBSD$");
/*
* ld128 version of k_expl.h. See ../ld80/s_expl.c for most comments.
@@ -265,7 +265,8 @@
/*
* XXX: the rest of the functions are identical for ld80 and ld128.
* However, we should use scalbnl() for ld128, since long double
- * multiplication is very slow on the only supported ld128 arch (sparc64).
+ * multiplication was very slow on sparc64 and no new evaluation has
+ * been made for aarch64 and/or riscv.
*/
static inline void
@@ -299,7 +300,7 @@
static inline long double complex
__ldexp_cexpl(long double complex z, int expt)
{
- long double exp_x, hi, lo;
+ long double c, exp_x, hi, lo, s;
long double x, y, scale1, scale2;
int half_expt, k;
@@ -307,16 +308,17 @@
y = cimagl(z);
__k_expl(x, &hi, &lo, &k);
- exp_x = (lo + hi) * 0x1p16382;
+ exp_x = (lo + hi) * 0x1p16382L;
expt += k - 16382;
scale1 = 1;
half_expt = expt / 2;
SET_LDBL_EXPSIGN(scale1, BIAS + half_expt);
scale2 = 1;
- SET_LDBL_EXPSIGN(scale1, BIAS + expt - half_expt);
+ SET_LDBL_EXPSIGN(scale2, BIAS + expt - half_expt);
- return (CMPLXL(cos(y) * exp_x * scale1 * scale2,
- sinl(y) * exp_x * scale1 * scale2));
+ sincosl(y, &s, &c);
+ return (CMPLXL(c * exp_x * scale1 * scale2,
+ s * exp_x * scale1 * scale2));
}
#endif /* _COMPLEX_H */
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c b/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c
index effeb78..ee3d2c7 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/s_exp2l.c 326219 2017-11-26 02:00:33Z pfg $");
+__FBSDID("$FreeBSD$");
#include <float.h>
#include <stdint.h>
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_expl.c b/libm/upstream-freebsd/lib/msun/ld128/s_expl.c
index f4c18be..5b786af 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_expl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_expl.c
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/s_expl.c 336545 2018-07-20 12:42:24Z bde $");
+__FBSDID("$FreeBSD$");
/*
* ld128 version of s_expl.c. See ../ld80/s_expl.c for most comments.
@@ -92,7 +92,10 @@
t = SUM2P(hi, lo);
/* Scale by 2**k. */
- /* XXX sparc64 multiplication is so slow that scalbnl() is faster. */
+ /*
+ * XXX sparc64 multiplication was so slow that scalbnl() is faster,
+ * but performance on aarch64 and riscv hasn't yet been quantified.
+ */
if (k >= LDBL_MIN_EXP) {
if (k == LDBL_MAX_EXP)
RETURNI(t * 2 * 0x1p16383L);
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_logl.c b/libm/upstream-freebsd/lib/msun/ld128/s_logl.c
index 6c9981b..93a2a7c 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_logl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_logl.c
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/lib/msun/ld128/s_logl.c 326219 2017-11-26 02:00:33Z pfg $");
+__FBSDID("$FreeBSD$");
/**
* Implementation of the natural logarithm of x for 128-bit format.
@@ -535,16 +535,17 @@
* efficiency than is gained.
*/
/*
- * Use double precision operations wherever possible, since long
- * double operations are emulated and are very slow on the only
- * known machines that support ld128 (sparc64). Also, don't try
- * to improve parallelism by increasing the number of operations,
- * since any parallelism on such machines is needed for the
- * emulation. Horner's method is good for this, and is also good
- * for accuracy. Horner's method doesn't handle the `lo' term
- * well, either for efficiency or accuracy. However, for accuracy
- * we evaluate d * d * P2 separately to take advantage of
- * by P2 being exact, and this gives a good place to sum the 'lo'
+ * Use double precision operations wherever possible, since
+ * long double operations are emulated and were very slow on
+ * the old sparc64 and unknown on the newer aarch64 and riscv
+ * machines. Also, don't try to improve parallelism by
+ * increasing the number of operations, since any parallelism
+ * on such machines is needed for the emulation. Horner's
+ * method is good for this, and is also good for accuracy.
+ * Horner's method doesn't handle the `lo' term well, either
+ * for efficiency or accuracy. However, for accuracy we
+ * evaluate d * d * P2 separately to take advantage of by P2
+ * being exact, and this gives a good place to sum the 'lo'
* term too.
*/
dd = (double)d;
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c b/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c
index 1b8196f..45d10e5 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/lib/msun/ld128/s_nanl.c 326219 2017-11-26 02:00:33Z pfg $
+ * $FreeBSD$
*/
#include <math.h>