about summary refs log tree commit diff
path: root/src/internal
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2017-10-22 18:06:00 +0000
committerRich Felker <dalias@aerifal.cx>2019-04-17 23:43:53 -0400
commit3f94c648ef32c95fa7f5c94b5cb8f2b764fc1938 (patch)
tree078300c87fed8d8e673f1b94ef4e6bad95cf587a /src/internal
parent098868b338e9afd3ef844070a94b9b10360d913f (diff)
downloadmusl-3f94c648ef32c95fa7f5c94b5cb8f2b764fc1938.tar.gz
musl-3f94c648ef32c95fa7f5c94b5cb8f2b764fc1938.tar.xz
musl-3f94c648ef32c95fa7f5c94b5cb8f2b764fc1938.zip
math: new exp2f and expf
from https://github.com/ARM-software/optimized-routines,
commit 04884bd04eac4b251da4026900010ea7d8850edc

In expf TOINT_INTRINSICS is kept, but is unused, it would require support
for __builtin_round and __builtin_lround as single instruction.

code size change: +94 bytes.
benchmark on x86_64 before, after, speedup:

-Os:
  expf rthruput:   9.19 ns/call  8.11 ns/call 1.13x
   expf latency:  34.19 ns/call 18.77 ns/call 1.82x
 exp2f rthruput:   5.59 ns/call  6.52 ns/call 0.86x
  exp2f latency:  17.93 ns/call 16.70 ns/call 1.07x
-O3:
  expf rthruput:   9.12 ns/call  4.92 ns/call 1.85x
   expf latency:  34.44 ns/call 18.99 ns/call 1.81x
 exp2f rthruput:   5.58 ns/call  4.49 ns/call 1.24x
  exp2f latency:  17.95 ns/call 16.94 ns/call 1.06x
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/libm.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/internal/libm.h b/src/internal/libm.h
index 5212bab1..98bf5c68 100644
--- a/src/internal/libm.h
+++ b/src/internal/libm.h
@@ -64,6 +64,22 @@ union ldshape {
 /* Support signaling NaNs.  */
 #define WANT_SNAN 0
 
+#ifndef TOINT_INTRINSICS
+#define TOINT_INTRINSICS 0
+#endif
+
+#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 double_t roundtoint(double_t);
+
+/* 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 int32_t converttoint(double_t);
+#endif
+
 /* Helps static branch prediction so hot path can be better optimized.  */
 #ifdef __GNUC__
 #define predict_true(x) __builtin_expect(!!(x), 1)