Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2018-07-05 14:37:25 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-07-06 11:29:01 +0300
commit393a1cb4eaeadbc67587a009328715bbc42e56b7 (patch)
tree49a0f0fa761c493330873f81faee2ff6a92c1f32 /newlib/libm
parentcbe50607fb4741bd96e8de726ad89d0ec3d9f427 (diff)
Move __HAVE_FAST_FMA to math_config.h
Define it consistently with other HAVE_* macros that only affect code using math_config.h. This is also closer to the Arm Optimized Routines code.
Diffstat (limited to 'newlib/libm')
-rw-r--r--newlib/libm/common/log.c2
-rw-r--r--newlib/libm/common/log2.c4
-rw-r--r--newlib/libm/common/log2_data.c4
-rw-r--r--newlib/libm/common/log_data.c4
-rw-r--r--newlib/libm/common/math_config.h13
-rw-r--r--newlib/libm/common/pow.c6
6 files changed, 21 insertions, 12 deletions
diff --git a/newlib/libm/common/log.c b/newlib/libm/common/log.c
index 2e350749f..35329392d 100644
--- a/newlib/libm/common/log.c
+++ b/newlib/libm/common/log.c
@@ -146,7 +146,7 @@ log (double x)
/* log(x) = log1p(z/c-1) + log(c) + k*Ln2. */
/* r ~= z/c - 1, |r| < 1/(2*N). */
-#if __HAVE_FAST_FMA
+#if HAVE_FAST_FMA
/* rounding error: 0x1p-55/N. */
r = fma (z, invc, -1.0);
#else
diff --git a/newlib/libm/common/log2.c b/newlib/libm/common/log2.c
index a2da93e74..00eb406b2 100644
--- a/newlib/libm/common/log2.c
+++ b/newlib/libm/common/log2.c
@@ -72,7 +72,7 @@ double
if (WANT_ROUNDING && unlikely (ix == asuint64 (1.0)))
return 0;
r = x - 1.0;
-#if __HAVE_FAST_FMA
+#if HAVE_FAST_FMA
hi = r * InvLn2hi;
lo = r * InvLn2lo + fma (r, InvLn2hi, -hi);
#else
@@ -123,7 +123,7 @@ double
/* log2(x) = log2(z/c) + log2(c) + k. */
/* r ~= z/c - 1, |r| < 1/(2*N). */
-#if __HAVE_FAST_FMA
+#if HAVE_FAST_FMA
/* rounding error: 0x1p-55/N. */
r = fma (z, invc, -1.0);
t1 = r * InvLn2hi;
diff --git a/newlib/libm/common/log2_data.c b/newlib/libm/common/log2_data.c
index c3e5fa688..ee9efcc2a 100644
--- a/newlib/libm/common/log2_data.c
+++ b/newlib/libm/common/log2_data.c
@@ -134,7 +134,7 @@ const struct log2_data __log2_data = {
{0x1.767dcf99eff8cp-1, 0x1.ce0a43dbf4000p-2},
#endif
},
-#if !__HAVE_FAST_FMA
+#if !HAVE_FAST_FMA
.tab2 = {
# if N == 64
{0x1.6200012b90a8ep-1, 0x1.904ab0644b605p-55},
@@ -203,6 +203,6 @@ const struct log2_data __log2_data = {
{0x1.5dfffebfc3481p+0, -0x1.180902e30e93ep-54},
# endif
},
-#endif /* !__HAVE_FAST_FMA */
+#endif /* !HAVE_FAST_FMA */
};
#endif /* __OBSOLETE_MATH */
diff --git a/newlib/libm/common/log_data.c b/newlib/libm/common/log_data.c
index ef62677ca..26b9c3f44 100644
--- a/newlib/libm/common/log_data.c
+++ b/newlib/libm/common/log_data.c
@@ -307,7 +307,7 @@ const struct log_data __log_data = {
{0x1.756cadbd6130cp-1, 0x1.432eee32fe000p-2},
#endif
},
-#if !__HAVE_FAST_FMA
+#if !HAVE_FAST_FMA
.tab2 = {
# if N == 64
{0x1.61ffff94c4fecp-1, -0x1.9fe4fc998f325p-56},
@@ -505,6 +505,6 @@ const struct log_data __log_data = {
{0x1.5efffe7b87a89p+0, -0x1.47eb780ed6904p-54},
#endif
},
-#endif /* !__HAVE_FAST_FMA */
+#endif /* !HAVE_FAST_FMA */
};
#endif /* __OBSOLETE_MATH */
diff --git a/newlib/libm/common/math_config.h b/newlib/libm/common/math_config.h
index aec9cd0d6..1f83756ab 100644
--- a/newlib/libm/common/math_config.h
+++ b/newlib/libm/common/math_config.h
@@ -61,6 +61,15 @@
# endif
#endif
+/* Compiler can inline fma as a single instruction. */
+#ifndef HAVE_FAST_FMA
+# if __aarch64__ || __ARM_FEATURE_FMA
+# define HAVE_FAST_FMA 1
+# else
+# define HAVE_FAST_FMA 0
+# endif
+#endif
+
#if HAVE_FAST_ROUND
# define TOINT_INTRINSICS 1
@@ -366,7 +375,7 @@ extern const struct log_data
double poly[LOG_POLY_ORDER - 1]; /* First coefficient is 1. */
double poly1[LOG_POLY1_ORDER - 1];
struct {double invc, logc;} tab[1 << LOG_TABLE_BITS];
-#if !__HAVE_FAST_FMA
+#if !HAVE_FAST_FMA
struct {double chi, clo;} tab2[1 << LOG_TABLE_BITS];
#endif
} __log_data HIDDEN;
@@ -381,7 +390,7 @@ extern const struct log2_data
double poly[LOG2_POLY_ORDER - 1];
double poly1[LOG2_POLY1_ORDER - 1];
struct {double invc, logc;} tab[1 << LOG2_TABLE_BITS];
-#if !__HAVE_FAST_FMA
+#if !HAVE_FAST_FMA
struct {double chi, clo;} tab2[1 << LOG2_TABLE_BITS];
#endif
} __log2_data HIDDEN;
diff --git a/newlib/libm/common/pow.c b/newlib/libm/common/pow.c
index 7d8060751..11964e343 100644
--- a/newlib/libm/common/pow.c
+++ b/newlib/libm/common/pow.c
@@ -80,7 +80,7 @@ log_inline (uint64_t ix, double_t *tail)
logctail = T[i].logctail;
/* r = z/c - 1, arranged to be exact. */
-#if __HAVE_FAST_FMA
+#if HAVE_FAST_FMA
r = fma (z, invc, -1.0);
#else
double_t zhi = asdouble (iz & (-1ULL << 32));
@@ -102,7 +102,7 @@ log_inline (uint64_t ix, double_t *tail)
ar2 = r * ar;
ar3 = r * ar2;
/* k*Ln2 + log(c) + r + A[0]*r*r. */
-#if __HAVE_FAST_FMA
+#if HAVE_FAST_FMA
hi = t2 + ar2;
lo3 = fma (ar, r, -ar2);
lo4 = t2 - hi + ar2;
@@ -376,7 +376,7 @@ pow (double x, double y)
double_t lo;
double_t hi = log_inline (ix, &lo);
double_t ehi, elo;
-#if __HAVE_FAST_FMA
+#if HAVE_FAST_FMA
ehi = y * hi;
elo = y * lo + fma (y, hi, -ehi);
#else