diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-12-29 19:37:22 -0500 |
---|---|---|
committer | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2011-12-29 19:37:22 -0500 |
commit | 69573077ca04c05fb12e177747711d7ef197a9c8 (patch) | |
tree | 351d03f6b880902c14b2f4b77b2776d23f02e19b | |
parent | bb365f5895571160988214f760734129a7f3bf5d (diff) | |
download | glibc-69573077ca04c05fb12e177747711d7ef197a9c8.zip glibc-69573077ca04c05fb12e177747711d7ef197a9c8.tar.gz glibc-69573077ca04c05fb12e177747711d7ef197a9c8.tar.bz2 |
Optimize libm
libm is now somewhat integrated with gcc's -ffinite-math-only option
and lots of the wrapper functions have been optimized.
Backport of commit #0ac5ae2335292908f39031b1ea9fe8edce433c0f
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/halfulp.c | 18 | ||||
-rw-r--r-- | sysdeps/powerpc/fpu/e_hypot.c | 1 | ||||
-rw-r--r-- | sysdeps/powerpc/fpu/e_hypotf.c | 1 | ||||
-rw-r--r-- | sysdeps/powerpc/fpu/e_sqrt.c | 21 | ||||
-rw-r--r-- | sysdeps/powerpc/fpu/e_sqrtf.c | 19 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/fpu/e_sqrt.c | 3 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/fpu/e_sqrtf.c | 3 |
8 files changed, 35 insertions, 43 deletions
@@ -1,3 +1,15 @@ +2011-10-12 Ulrich Drepper <drepper@gmail.com> + + Add integration with gcc's -ffinite-math-only and optimize wrapper + functions in libm. + * sysdeps/powerpc/fpu/e_hypot.c: Add __*_finite alias. + * sysdeps/powerpc/fpu/e_hypotf.c: Likewise. + * sysdeps/powerpc/fpu/e_sqrt.c: Likewise. + * sysdeps/powerpc/fpu/e_sqrtf.c: Likewise. + * sysdeps/powerpc/powerpc64/fpu/e_sqrt.c: Likewise. + * sysdeps/powerpc/powerpc64/fpu/e_sqrtf.c: Likewise. + * sysdeps/ieee754/dbl-64/halfulp.c: Likewise. + 2011-09-15 Andreas Schwab <schwab@redhat.com> * sysdeps/powerpc/fpu/e_hypot.c (__ieee754_hypot): Use diff --git a/sysdeps/ieee754/dbl-64/halfulp.c b/sysdeps/ieee754/dbl-64/halfulp.c index 478a4ba..42b21fb 100644 --- a/sysdeps/ieee754/dbl-64/halfulp.c +++ b/sysdeps/ieee754/dbl-64/halfulp.c @@ -1,7 +1,7 @@ /* * IBM Accurate Mathematical Library * written by International Business Machines Corp. - * Copyright (C) 2001, 2005 Free Software Foundation + * Copyright (C) 2001, 2005, 2011 Free Software Foundation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -40,13 +40,11 @@ #include "dla.h" #include "math_private.h" -double __ieee754_sqrt(double x); - static const int4 tab54[32] = { 262143, 11585, 1782, 511, 210, 107, 63, 42, 30, 22, 17, 14, 12, 10, 9, 7, - 7, 6, 5, 5, 5, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3 }; + 7, 6, 5, 5, 5, 4, 4, 4, + 3, 3, 3, 3, 3, 3, 3, 3 }; double __halfulp(double x, double y) @@ -64,12 +62,12 @@ double __halfulp(double x, double y) z = (double) k; return (z*y == -1075.0)?0: -10.0; } - /* if y > 0 */ + /* if y > 0 */ v.x = y; if (v.i[LOW_HALF] != 0) return -10.0; v.x=x; - /* case where x = 2**n for some integer n */ + /* case where x = 2**n for some integer n */ if (((v.i[HIGH_HALF]&0x000fffff)|v.i[LOW_HALF]) == 0) { k=(v.i[HIGH_HALF]>>20)-1023; return (((double) k)*y == -1075.0)?0:-10.0; @@ -90,7 +88,7 @@ double __halfulp(double x, double y) k = -k; if (k>5) return -10.0; - /* now treat x */ + /* now treat x */ while (k>0) { z = __ieee754_sqrt(x); EMULV(z,z,u,uu,j1,j2,j3,j4,j5); @@ -111,11 +109,11 @@ double __halfulp(double x, double y) m = (k&0x000fffff)|0x00100000; m = m>>(20-l); /* m is the odd integer of x */ - /* now check whether the length of m**n is at most 54 bits */ + /* now check whether the length of m**n is at most 54 bits */ if (m > tab54[n-3]) return -10.0; - /* yes, it is - now compute x**n by simple multiplications */ + /* yes, it is - now compute x**n by simple multiplications */ u = x; for (k=1;k<n;k++) u = u*x; diff --git a/sysdeps/powerpc/fpu/e_hypot.c b/sysdeps/powerpc/fpu/e_hypot.c index afbcc18..a8d67d8 100644 --- a/sysdeps/powerpc/fpu/e_hypot.c +++ b/sysdeps/powerpc/fpu/e_hypot.c @@ -115,3 +115,4 @@ __ieee754_hypot (double x, double y) } return __ieee754_sqrt (x * x + y * y); } +strong_alias (__ieee754_hypot, __hypot_finite) diff --git a/sysdeps/powerpc/fpu/e_hypotf.c b/sysdeps/powerpc/fpu/e_hypotf.c index 02ad773..915738c 100644 --- a/sysdeps/powerpc/fpu/e_hypotf.c +++ b/sysdeps/powerpc/fpu/e_hypotf.c @@ -116,3 +116,4 @@ __ieee754_hypotf (float x, float y) } return __ieee754_sqrtf (x * x + y * y); } +strong_alias (__ieee754_hypotf, __hypotf_finite) diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c index e95b786..f9ded25 100644 --- a/sysdeps/powerpc/fpu/e_sqrt.c +++ b/sysdeps/powerpc/fpu/e_sqrt.c @@ -1,5 +1,5 @@ /* Double-precision floating point square root. - Copyright (C) 1997, 2002, 2003, 2004, 2008 Free Software Foundation, Inc. + Copyright (C) 1997, 2002-2004, 2008, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -46,21 +46,15 @@ extern const float __t_sqrt[1024]; generated guesses (which mostly runs on the integer unit, while the Newton-Raphson is running on the FPU). */ -#ifdef __STDC__ double __slow_ieee754_sqrt (double x) -#else -double -__slow_ieee754_sqrt (x) - double x; -#endif { const float inf = a_inf.value; if (x > 0) { /* schedule the EXTRACT_WORDS to get separation between the store - and the load. */ + and the load. */ ieee_double_shape_type ew_u; ieee_double_shape_type iw_u; ew_u.value = (x); @@ -147,7 +141,7 @@ __slow_ieee754_sqrt (x) else if (x < 0) { /* For some reason, some PowerPC32 processors don't implement - FE_INVALID_SQRT. */ + FE_INVALID_SQRT. */ #ifdef FE_INVALID_SQRT feraiseexcept (FE_INVALID_SQRT); @@ -160,14 +154,8 @@ __slow_ieee754_sqrt (x) return f_wash (x); } -#ifdef __STDC__ double __ieee754_sqrt (double x) -#else -double -__ieee754_sqrt (x) - double x; -#endif { double z; @@ -175,7 +163,7 @@ __ieee754_sqrt (x) if (__CPU_HAS_FSQRT) { /* Volatile is required to prevent the compiler from moving the - fsqrt instruction above the branch. */ + fsqrt instruction above the branch. */ __asm __volatile (" fsqrt %0,%1\n" :"=f" (z):"f" (x)); } @@ -184,3 +172,4 @@ __ieee754_sqrt (x) return z; } +strong_alias (__ieee754_sqrt, __sqrt_finite) diff --git a/sysdeps/powerpc/fpu/e_sqrtf.c b/sysdeps/powerpc/fpu/e_sqrtf.c index ca44fac..965faee 100644 --- a/sysdeps/powerpc/fpu/e_sqrtf.c +++ b/sysdeps/powerpc/fpu/e_sqrtf.c @@ -1,5 +1,5 @@ /* Single-precision floating point square root. - Copyright (C) 1997, 2003, 2004, 2008 Free Software Foundation, Inc. + Copyright (C) 1997, 2003, 2004, 2008, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -46,14 +46,8 @@ extern const float __t_sqrt[1024]; generated guesses (which mostly runs on the integer unit, while the Newton-Raphson is running on the FPU). */ -#ifdef __STDC__ float __slow_ieee754_sqrtf (float x) -#else -float -__slow_ieee754_sqrtf (x) - float x; -#endif { const float inf = a_inf.value; @@ -123,7 +117,7 @@ __slow_ieee754_sqrtf (x) else if (x < 0) { /* For some reason, some PowerPC32 processors don't implement - FE_INVALID_SQRT. */ + FE_INVALID_SQRT. */ #ifdef FE_INVALID_SQRT feraiseexcept (FE_INVALID_SQRT); @@ -137,14 +131,8 @@ __slow_ieee754_sqrtf (x) } -#ifdef __STDC__ float __ieee754_sqrtf (float x) -#else -float -__ieee754_sqrtf (x) - float x; -#endif { double z; @@ -152,7 +140,7 @@ __ieee754_sqrtf (x) if (__CPU_HAS_FSQRT) { /* Volatile is required to prevent the compiler from moving the - fsqrt instruction above the branch. */ + fsqrt instruction above the branch. */ __asm __volatile (" fsqrts %0,%1\n" :"=f" (z):"f" (x)); } @@ -161,3 +149,4 @@ __ieee754_sqrtf (x) return z; } +strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/sysdeps/powerpc/powerpc64/fpu/e_sqrt.c b/sysdeps/powerpc/powerpc64/fpu/e_sqrt.c index 0a229cb..314abba 100644 --- a/sysdeps/powerpc/powerpc64/fpu/e_sqrt.c +++ b/sysdeps/powerpc/powerpc64/fpu/e_sqrt.c @@ -1,5 +1,5 @@ /* Double-precision floating point square root. - Copyright (C) 1997, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1997, 2002-2004, 2006, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,3 +27,4 @@ __ieee754_sqrt (double x) __asm __volatile ("fsqrt %0,%1" : "=f" (z) : "f" (x)); return z; } +strong_alias (__ieee754_sqrt, __sqrt_finite) diff --git a/sysdeps/powerpc/powerpc64/fpu/e_sqrtf.c b/sysdeps/powerpc/powerpc64/fpu/e_sqrtf.c index 0f17a64..7157214 100644 --- a/sysdeps/powerpc/powerpc64/fpu/e_sqrtf.c +++ b/sysdeps/powerpc/powerpc64/fpu/e_sqrtf.c @@ -1,5 +1,5 @@ /* Single-precision floating point square root. - Copyright (C) 1997, 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1997, 2003, 2004, 2006, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,3 +27,4 @@ __ieee754_sqrtf (float x) __asm ("fsqrts %0,%1" : "=f" (z) : "f" (x)); return z; } +strong_alias (__ieee754_sqrtf, __sqrtf_finite) |