aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--sysdeps/aarch64/fpu/math_private.h17
-rw-r--r--sysdeps/ieee754/flt-32/e_expf.c5
-rw-r--r--sysdeps/ieee754/flt-32/math_config.h20
4 files changed, 36 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 48fd7eb..54c4b5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2018-08-10 Wilco Dijkstra <wdijkstr@arm.com>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * sysdeps/aarch64/fpu/math_private.h (roundtoint): Use round.
+ (converttoint): Use lround.
+ * sysdeps/ieee754/flt-32/math_config.h (roundtoint): Declare and
+ document the semantics when TOINT_INTRINSICS is set.
+ (converttoint): Likewise.
+ (TOINT_RINT): Remove.
+ (TOINT_SHIFT): Remove.
+ * sysdeps/ieee754/flt-32/e_expf.c (__expf): Remove the TOINT_RINT code
+ path.
+
2018-08-10 Florian Weimer <fweimer@redhat.com>
[BZ #23497]
diff --git a/sysdeps/aarch64/fpu/math_private.h b/sysdeps/aarch64/fpu/math_private.h
index fcd02c0..d2e0abc 100644
--- a/sysdeps/aarch64/fpu/math_private.h
+++ b/sysdeps/aarch64/fpu/math_private.h
@@ -21,6 +21,8 @@
#include <fenv.h>
#include <fpu_control.h>
+#include <stdint.h>
+#include <math.h>
static __always_inline void
libc_feholdexcept_aarch64 (fenv_t *envp)
@@ -298,25 +300,20 @@ libc_feresetround_noex_aarch64_ctx (struct rm_ctx *ctx)
#define libc_feresetround_noexf_ctx libc_feresetround_noex_aarch64_ctx
#define libc_feresetround_noexl_ctx libc_feresetround_noex_aarch64_ctx
-/* Hack: only include the large arm_neon.h when needed. */
-#ifdef _MATH_CONFIG_H
-# include <arm_neon.h>
-
-/* ACLE intrinsics for frintn and fcvtns instructions. */
-# define TOINT_INTRINSICS 1
+/* Use inline round and lround instructions. */
+#define TOINT_INTRINSICS 1
static inline double_t
roundtoint (double_t x)
{
- return vget_lane_f64 (vrndn_f64 (vld1_f64 (&x)), 0);
+ return round (x);
}
-static inline uint64_t
+static inline int32_t
converttoint (double_t x)
{
- return vcvtnd_s64_f64 (x);
+ return lround (x);
}
-#endif
#include_next <math_private.h>
diff --git a/sysdeps/ieee754/flt-32/e_expf.c b/sysdeps/ieee754/flt-32/e_expf.c
index f2238bf..384a586 100644
--- a/sysdeps/ieee754/flt-32/e_expf.c
+++ b/sysdeps/ieee754/flt-32/e_expf.c
@@ -85,10 +85,7 @@ __expf (float x)
#if TOINT_INTRINSICS
kd = roundtoint (z);
ki = converttoint (z);
-#elif TOINT_RINT
- kd = rint (z);
- ki = (long) kd;
-#elif TOINT_SHIFT
+#else
# define SHIFT __exp2f_data.shift
kd = math_narrow_eval ((double) (z + SHIFT)); /* Needs to be double. */
ki = asuint64 (kd);
diff --git a/sysdeps/ieee754/flt-32/math_config.h b/sysdeps/ieee754/flt-32/math_config.h
index 9c4ef30..8ca7532 100644
--- a/sysdeps/ieee754/flt-32/math_config.h
+++ b/sysdeps/ieee754/flt-32/math_config.h
@@ -38,13 +38,23 @@
#endif
#ifndef TOINT_INTRINSICS
+/* When set, the roundtoint and converttoint functions are provided with
+ the semantics documented below. */
# define TOINT_INTRINSICS 0
#endif
-#ifndef TOINT_RINT
-# define TOINT_RINT 0
-#endif
-#ifndef TOINT_SHIFT
-# define TOINT_SHIFT 1
+
+#if TOINT_INTRINSICS
+/* Round x to nearest int in all rounding modes, ties have to be rounded
+ consistently with converttoint so the results match. If the result
+ would be outside of [-2^31, 2^31-1] then the semantics is unspecified. */
+static inline double_t
+roundtoint (double_t x);
+
+/* Convert x to nearest int in all rounding modes, ties have to be rounded
+ consistently with roundtoint. If the result is not representible in an
+ int32_t then the semantics is unspecified. */
+static inline int32_t
+converttoint (double_t x);
#endif
static inline uint32_t