about summary refs log tree commit diff
path: root/src/math/log2_data.h
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2018-12-01 00:53:54 +0000
committerRich Felker <dalias@aerifal.cx>2019-04-17 23:45:13 -0400
commit2a3210cf4abff0a69ff3e7adc66591dfe6ab2197 (patch)
tree6fd3ac932c34d33a48c0604a7fcf5b1b8760b83d /src/math/log2_data.h
parent236cd056e871acb8731cd84b5bfb6f0feb646589 (diff)
downloadmusl-2a3210cf4abff0a69ff3e7adc66591dfe6ab2197.tar.gz
musl-2a3210cf4abff0a69ff3e7adc66591dfe6ab2197.tar.xz
musl-2a3210cf4abff0a69ff3e7adc66591dfe6ab2197.zip
math: new log2
from https://github.com/ARM-software/optimized-routines,
commit 04884bd04eac4b251da4026900010ea7d8850edc

code size change: +2458 bytes (+1524 bytes with fma).
benchmark on x86_64 before, after, speedup:

-Os:
  log2 rthruput:  16.08 ns/call 10.49 ns/call 1.53x
   log2 latency:  44.54 ns/call 25.55 ns/call 1.74x
-O3:
  log2 rthruput:  15.92 ns/call 10.11 ns/call 1.58x
   log2 latency:  44.66 ns/call 26.16 ns/call 1.71x
Diffstat (limited to 'src/math/log2_data.h')
-rw-r--r--src/math/log2_data.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/math/log2_data.h b/src/math/log2_data.h
new file mode 100644
index 00000000..276a786d
--- /dev/null
+++ b/src/math/log2_data.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018, Arm Limited.
+ * SPDX-License-Identifier: MIT
+ */
+#ifndef _LOG2_DATA_H
+#define _LOG2_DATA_H
+
+#include <features.h>
+
+#define LOG2_TABLE_BITS 6
+#define LOG2_POLY_ORDER 7
+#define LOG2_POLY1_ORDER 11
+extern hidden const struct log2_data {
+	double invln2hi;
+	double invln2lo;
+	double poly[LOG2_POLY_ORDER - 1];
+	double poly1[LOG2_POLY1_ORDER - 1];
+	struct {
+		double invc, logc;
+	} tab[1 << LOG2_TABLE_BITS];
+#if !__FP_FAST_FMA
+	struct {
+		double chi, clo;
+	} tab2[1 << LOG2_TABLE_BITS];
+#endif
+} __log2_data;
+
+#endif