diff mbox

Use builtins in signbit implementation

Message ID 001401d0e723$29cdf720$7d69e560$@com
State New
Headers show

Commit Message

Wilco Sept. 4, 2015, 3:05 p.m. UTC
Use the GCC builtin functions for the non-inlined signbit implementations.
This excludes the 128ibm format as I'm not sure whether the builtins work 
for that case.

OK for commit?

ChangeLog: 
2015-09-04  Wilco Dijkstra  <wdijkstr@arm.com>
	
	* sysdeps/ieee754/dbl-64/s_signbit.c (__signbit):
	Use __builtin_signbit. 	
	* sysdeps/ieee754/flt-32/s_signbitf.c (__signbitf):
	Use __builtin_signbitf.
	* sysdeps/ieee754/ldbl-128/s_signbitl.c (__signbitl):
	Use __builtin_signbitl.	
	* sysdeps/ieee754/ldbl-96/s_signbitl.c (__signbitl): Likewise.

---
 sysdeps/ieee754/dbl-64/s_signbit.c    | 6 +-----
 sysdeps/ieee754/flt-32/s_signbitf.c   | 6 +-----
 sysdeps/ieee754/ldbl-128/s_signbitl.c | 6 +-----
 sysdeps/ieee754/ldbl-96/s_signbitl.c  | 6 +-----
 4 files changed, 4 insertions(+), 20 deletions(-)

Comments

Joseph Myers Sept. 4, 2015, 3:31 p.m. UTC | #1
On Fri, 4 Sep 2015, Wilco Dijkstra wrote:

> Use the GCC builtin functions for the non-inlined signbit implementations.
> This excludes the 128ibm format as I'm not sure whether the builtins work 
> for that case.

signbit should work fine for ldbl-128ibm (it's copysign and fabs that have 
issues in some cases).

> @@ -19,13 +19,9 @@
>  
>  #include <math.h>
>  
> -#include <math_private.h>
>  

I'd say that when removing this #include, one of the blank lines about it 
should be removed as well.
diff mbox

Patch

diff --git a/sysdeps/ieee754/dbl-64/s_signbit.c b/sysdeps/ieee754/dbl-64/s_signbit.c
index 764f11a..41fca00 100644
--- a/sysdeps/ieee754/dbl-64/s_signbit.c
+++ b/sysdeps/ieee754/dbl-64/s_signbit.c
@@ -19,13 +19,9 @@ 
 
 #include <math.h>
 
-#include <math_private.h>
 
 int
 __signbit (double x)
 {
-  int32_t hx;
-
-  GET_HIGH_WORD (hx, x);
-  return hx & 0x80000000;
+  return __builtin_signbit (x);
 }
diff --git a/sysdeps/ieee754/flt-32/s_signbitf.c b/sysdeps/ieee754/flt-32/s_signbitf.c
index 169820e..7be7b6e 100644
--- a/sysdeps/ieee754/flt-32/s_signbitf.c
+++ b/sysdeps/ieee754/flt-32/s_signbitf.c
@@ -19,13 +19,9 @@ 
 
 #include <math.h>
 
-#include <math_private.h>
 
 int
 __signbitf (float x)
 {
-  int32_t hx;
-
-  GET_FLOAT_WORD (hx, x);
-  return hx & 0x80000000;
+  return __builtin_signbitf (x);
 }
diff --git a/sysdeps/ieee754/ldbl-128/s_signbitl.c b/sysdeps/ieee754/ldbl-128/s_signbitl.c
index acfe859..cc5f16e 100644
--- a/sysdeps/ieee754/ldbl-128/s_signbitl.c
+++ b/sysdeps/ieee754/ldbl-128/s_signbitl.c
@@ -19,13 +19,9 @@ 
 
 #include <math.h>
 
-#include <math_private.h>
 
 int
 __signbitl (long double x)
 {
-  int64_t e;
-
-  GET_LDOUBLE_MSW64 (e, x);
-  return e < 0;
+  return __builtin_signbitl (x);
 }
diff --git a/sysdeps/ieee754/ldbl-96/s_signbitl.c b/sysdeps/ieee754/ldbl-96/s_signbitl.c
index bbe72a6..cc5f16e 100644
--- a/sysdeps/ieee754/ldbl-96/s_signbitl.c
+++ b/sysdeps/ieee754/ldbl-96/s_signbitl.c
@@ -19,13 +19,9 @@ 
 
 #include <math.h>
 
-#include <math_private.h>
 
 int
 __signbitl (long double x)
 {
-  int32_t e;
-
-  GET_LDOUBLE_EXP (e, x);
-  return e & 0x8000;
+  return __builtin_signbitl (x);
 }