[4/4] Do not wrap expf and exp2f

Message ID 59B90D0F.1000207@arm.com
State New, archived
Headers

Commit Message

Szabolcs Nagy Sept. 13, 2017, 10:48 a.m. UTC
  The new generic expf and exp2f code don't need wrappers any
more, they set errno inline, so only use the wrappers on
targets that need it. (The top level wrapper code is included
into sysdeps dirs where the wrapper is needed and empty
w_exp*f.c where the wrapper is suppressed).

A powerpc64 expf implementation includes the expf c code
directly which needed some changes.

2017-09-13  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* sysdeps/ieee754/flt-32/e_exp2f.c (__exp2f): Define without wrapper.
	* sysdeps/ieee754/flt-32/e_expf.c (__expf): Likewise
	* sysdeps/ieee754/flt-32/w_exp2f.c: New file.
	* sysdeps/ieee754/flt-32/w_expf.c: New file.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c: Update for
	the new expf code.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_expf.c: New file.
	* sysdeps/i386/fpu/w_exp2f.c: New file.
	* sysdeps/i386/fpu/w_expf.c: New file.
	* sysdeps/i386/i686/fpu/multiarch/w_expf.c: New file.
	* sysdeps/x86_64/fpu/w_expf.c: New file.
  

Comments

Joseph Myers Sept. 13, 2017, 8:19 p.m. UTC | #1
On Wed, 13 Sep 2017, Szabolcs Nagy wrote:

> 	* sysdeps/x86_64/fpu/w_expf.c: New file.

I don't think having w_expf.c alongside w_expf.S in the same directory 
makes sense.  (An IFUNC w_expf.c in the multiarch subdirectory, used to 
build both fma and non-fma versions and replacing the existing 
e_expf-fma.S, may well make sense if benchmarks show improvements on the 
fma and non-fma .S files.)
  
Arjan van de Ven Sept. 14, 2017, 12:31 a.m. UTC | #2
On 9/13/2017 1:19 PM, Joseph Myers wrote:
> On Wed, 13 Sep 2017, Szabolcs Nagy wrote:
> 
>> 	* sysdeps/x86_64/fpu/w_expf.c: New file.
> 
> I don't think having w_expf.c alongside w_expf.S in the same directory
> makes sense.  (An IFUNC w_expf.c in the multiarch subdirectory, used to
> build both fma and non-fma versions and replacing the existing
> e_expf-fma.S, may well make sense if benchmarks show improvements on the
> fma and non-fma .S files.)

fwiw I am assuming we'll retire the x86-64 .S files and use the C version
(for both FMA and non-FMA with some IFUNC selector) once this lands.
Optimizing the .S file was fun for FMA, but the C version has a smaller
polynomial and is faster ... data speaks and this wins.
  

Patch

From ba8143da8b2d0a25e1c4ed42704d46a720ebc3e1 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Tue, 12 Sep 2017 12:44:18 +0100
Subject: [PATCH 4/4] no wrapper

---
 sysdeps/i386/fpu/w_exp2f.c                             | 1 +
 sysdeps/i386/fpu/w_expf.c                              | 1 +
 sysdeps/i386/i686/fpu/multiarch/w_expf.c               | 1 +
 sysdeps/ieee754/flt-32/e_exp2f.c                       | 7 +++++--
 sysdeps/ieee754/flt-32/e_expf.c                        | 8 ++++++--
 sysdeps/ieee754/flt-32/w_exp2f.c                       | 1 +
 sysdeps/ieee754/flt-32/w_expf.c                        | 1 +
 sysdeps/m68k/m680x0/fpu/w_expf.c                       | 1 +
 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c | 7 ++++++-
 sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c       | 1 +
 sysdeps/x86_64/fpu/w_expf.c                            | 1 +
 11 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100644 sysdeps/i386/fpu/w_exp2f.c
 create mode 100644 sysdeps/i386/fpu/w_expf.c
 create mode 100644 sysdeps/i386/i686/fpu/multiarch/w_expf.c
 create mode 100644 sysdeps/ieee754/flt-32/w_exp2f.c
 create mode 100644 sysdeps/ieee754/flt-32/w_expf.c
 create mode 100644 sysdeps/m68k/m680x0/fpu/w_expf.c
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
 create mode 100644 sysdeps/x86_64/fpu/w_expf.c

diff --git a/sysdeps/i386/fpu/w_exp2f.c b/sysdeps/i386/fpu/w_exp2f.c
new file mode 100644
index 0000000000..4418f8bed5
--- /dev/null
+++ b/sysdeps/i386/fpu/w_exp2f.c
@@ -0,0 +1 @@ 
+#include <math/w_exp2f.c>
diff --git a/sysdeps/i386/fpu/w_expf.c b/sysdeps/i386/fpu/w_expf.c
new file mode 100644
index 0000000000..b471bccdb1
--- /dev/null
+++ b/sysdeps/i386/fpu/w_expf.c
@@ -0,0 +1 @@ 
+#include <math/w_expf.c>
diff --git a/sysdeps/i386/i686/fpu/multiarch/w_expf.c b/sysdeps/i386/i686/fpu/multiarch/w_expf.c
new file mode 100644
index 0000000000..b471bccdb1
--- /dev/null
+++ b/sysdeps/i386/i686/fpu/multiarch/w_expf.c
@@ -0,0 +1 @@ 
+#include <math/w_expf.c>
diff --git a/sysdeps/ieee754/flt-32/e_exp2f.c b/sysdeps/ieee754/flt-32/e_exp2f.c
index be53e5c699..7a3c5fdcff 100644
--- a/sysdeps/ieee754/flt-32/e_exp2f.c
+++ b/sysdeps/ieee754/flt-32/e_exp2f.c
@@ -18,6 +18,7 @@ 
 
 #include <math.h>
 #include <stdint.h>
+#include <shlib-compat.h>
 #include "math_config.h"
 
 /*
@@ -42,7 +43,7 @@  top12 (float x)
 }
 
 float
-__ieee754_exp2f (float x)
+__exp2f (float x)
 {
   uint32_t abstop;
   uint64_t ki, t;
@@ -85,4 +86,6 @@  __ieee754_exp2f (float x)
   y = y * s;
   return (float) y;
 }
-strong_alias (__ieee754_exp2f, __exp2f_finite)
+strong_alias (__exp2f, __ieee754_exp2f)
+strong_alias (__exp2f, __exp2f_finite)
+versioned_symbol (libm, __exp2f, exp2f, GLIBC_2_27);
diff --git a/sysdeps/ieee754/flt-32/e_expf.c b/sysdeps/ieee754/flt-32/e_expf.c
index b8244a82cf..8a38c2a0c6 100644
--- a/sysdeps/ieee754/flt-32/e_expf.c
+++ b/sysdeps/ieee754/flt-32/e_expf.c
@@ -18,6 +18,7 @@ 
 
 #include <math.h>
 #include <stdint.h>
+#include <shlib-compat.h>
 #include "math_config.h"
 
 /*
@@ -42,7 +43,7 @@  top12 (float x)
 }
 
 float
-__ieee754_expf (float x)
+__expf (float x)
 {
   uint32_t abstop;
   uint64_t ki, t;
@@ -99,4 +100,7 @@  __ieee754_expf (float x)
   y = y * s;
   return (float) y;
 }
-strong_alias (__ieee754_expf, __expf_finite)
+hidden_def (__expf)
+strong_alias (__expf, __ieee754_expf)
+strong_alias (__expf, __expf_finite)
+versioned_symbol (libm, __expf, expf, GLIBC_2_27);
diff --git a/sysdeps/ieee754/flt-32/w_exp2f.c b/sysdeps/ieee754/flt-32/w_exp2f.c
new file mode 100644
index 0000000000..1cc8931700
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/w_exp2f.c
@@ -0,0 +1 @@ 
+/* Not needed.  */
diff --git a/sysdeps/ieee754/flt-32/w_expf.c b/sysdeps/ieee754/flt-32/w_expf.c
new file mode 100644
index 0000000000..1cc8931700
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/w_expf.c
@@ -0,0 +1 @@ 
+/* Not needed.  */
diff --git a/sysdeps/m68k/m680x0/fpu/w_expf.c b/sysdeps/m68k/m680x0/fpu/w_expf.c
new file mode 100644
index 0000000000..b471bccdb1
--- /dev/null
+++ b/sysdeps/m68k/m680x0/fpu/w_expf.c
@@ -0,0 +1 @@ 
+#include <math/w_expf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
index b236290ea2..cc23f06fb1 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
@@ -16,9 +16,14 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <shlib-compat.h>
 #undef strong_alias
 #define strong_alias(a, b)
+#undef hidden_def
+#define hidden_def(a)
+#undef versioned_symbol
+#define versioned_symbol(a, b, c, d)
 
-#define __ieee754_expf __ieee754_expf_ppc64
+#define __expf __ieee754_expf_ppc64
 
 #include <sysdeps/ieee754/flt-32/e_expf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
new file mode 100644
index 0000000000..b471bccdb1
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/w_expf.c
@@ -0,0 +1 @@ 
+#include <math/w_expf.c>
diff --git a/sysdeps/x86_64/fpu/w_expf.c b/sysdeps/x86_64/fpu/w_expf.c
new file mode 100644
index 0000000000..b471bccdb1
--- /dev/null
+++ b/sysdeps/x86_64/fpu/w_expf.c
@@ -0,0 +1 @@ 
+#include <math/w_expf.c>
-- 
2.11.0