Use builtins in signbit implementation
Commit Message
> Joseph Myers wrote:
> 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).
OK, I added that version as well.
> > @@ -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.
Done, see below:
ChangeLog:
2015-08-20 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 | 7 +------
sysdeps/ieee754/flt-32/s_signbitf.c | 7 +------
sysdeps/ieee754/ldbl-128/s_signbitl.c | 7 +------
sysdeps/ieee754/ldbl-128ibm/s_signbitl.c | 8 +-------
sysdeps/ieee754/ldbl-96/s_signbitl.c | 7 +------
5 files changed, 5 insertions(+), 31 deletions(-)
Comments
On Fri, 4 Sep 2015, Wilco Dijkstra wrote:
> ChangeLog:
> 2015-08-20 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.
OK with the ChangeLog fixed to include the ldbl-128ibm changes as well.
@@ -19,13 +19,8 @@
#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);
}
@@ -19,13 +19,8 @@
#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);
}
@@ -19,13 +19,8 @@
#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);
}
@@ -18,18 +18,12 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
-#include <math_private.h>
#include <math_ldbl_opt.h>
int
___signbitl (long double x)
{
- int64_t e;
- double xhi;
-
- xhi = ldbl_high (x);
- EXTRACT_WORDS64 (e, xhi);
- return e < 0;
+ return __builtin_signbitl (x);
}
#if IS_IN (libm)
long_double_symbol (libm, ___signbitl, __signbitl);
@@ -19,13 +19,8 @@
#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);
}