public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use builtins in fabs implementations
@ 2015-05-22 15:31 Wilco Dijkstra
  2015-05-22 16:42 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Wilco Dijkstra @ 2015-05-22 15:31 UTC (permalink / raw)
  To: libc-alpha

Since GLIBC is built with a modern GCC which always inlines __builtin_fabs, it is safe to use the
builtin for the definitions of fabs and fabsf (fabsl is typically emulated and unsafe in some cases,
see https://sourceware.org/ml/libc-alpha/2015-05/msg00336.html). This means targets no longer need
to define their own implementations.

OK for commit?

ChangeLog: 
2015-05-22  Wilco Dijkstra  <wdijkstr@arm.com>

        * sysdeps/ieee754/dbl-64/s_fabs.c: (__fabs): Call __builtin_fabs.  
        * sysdeps/ieee754/flt-32/s_fabsf.c: (__fabsf): Likewise.

---
 sysdeps/ieee754/dbl-64/s_fabs.c  | 6 +-----
 sysdeps/ieee754/flt-32/s_fabsf.c | 6 +-----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/sysdeps/ieee754/dbl-64/s_fabs.c b/sysdeps/ieee754/dbl-64/s_fabs.c
index c82c421..73c09a2 100644
--- a/sysdeps/ieee754/dbl-64/s_fabs.c
+++ b/sysdeps/ieee754/dbl-64/s_fabs.c
@@ -19,15 +19,11 @@ static char rcsid[] = "$NetBSD: s_fabs.c,v 1.7 1995/05/10 20:47:13 jtc Exp $";
  */
 
 #include <math.h>
-#include <math_private.h>
 
 double
 __fabs (double x)
 {
-  u_int32_t high;
-  GET_HIGH_WORD (high, x);
-  SET_HIGH_WORD (x, high & 0x7fffffff);
-  return x;
+  return __builtin_fabs (x);
 }
 weak_alias (__fabs, fabs)
 #ifdef NO_LONG_DOUBLE
diff --git a/sysdeps/ieee754/flt-32/s_fabsf.c b/sysdeps/ieee754/flt-32/s_fabsf.c
index c58aede..297abe6 100644
--- a/sysdeps/ieee754/flt-32/s_fabsf.c
+++ b/sysdeps/ieee754/flt-32/s_fabsf.c
@@ -22,13 +22,9 @@ static char rcsid[] = "$NetBSD: s_fabsf.c,v 1.4 1995/05/10 20:47:15 jtc Exp $";
  */
 
 #include <math.h>
-#include <math_private.h>
 
 float __fabsf(float x)
 {
-	u_int32_t ix;
-	GET_FLOAT_WORD(ix,x);
-	SET_FLOAT_WORD(x,ix&0x7fffffff);
-        return x;
+  return __builtin_fabsf (x);
 }
 weak_alias (__fabsf, fabsf)
-- 
1.9.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Use builtins in fabs implementations
  2015-05-22 15:31 [PATCH] Use builtins in fabs implementations Wilco Dijkstra
@ 2015-05-22 16:42 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2015-05-22 16:42 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: libc-alpha

On Fri, 22 May 2015, Wilco Dijkstra wrote:

> Since GLIBC is built with a modern GCC which always inlines 
> __builtin_fabs, it is safe to use the builtin for the definitions of 
> fabs and fabsf (fabsl is typically emulated and unsafe in some cases, 
> see https://sourceware.org/ml/libc-alpha/2015-05/msg00336.html). This 
> means targets no longer need to define their own implementations.
> 
> OK for commit?

OK if you've at least run the math/ tests with clean results for at least 
one configuration.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-22 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-22 15:31 [PATCH] Use builtins in fabs implementations Wilco Dijkstra
2015-05-22 16:42 ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).