diff options
| author | Ulrich Drepper <drepper@gmail.com> | 2011-10-22 13:17:30 -0400 |
|---|---|---|
| committer | Ulrich Drepper <drepper@gmail.com> | 2011-10-22 13:17:30 -0400 |
| commit | 77425c63e72bc0c01d81bc7e9ba4bb41d11679e6 (patch) | |
| tree | c4fea5ed8070fc251140eba66b009bca1ff0e3b5 | |
| parent | bc62c2fb152d6ffec63975d88fd8f1bc3d3b7c01 (diff) | |
| download | glibc-77425c63e72bc0c01d81bc7e9ba4bb41d11679e6.tar.xz glibc-77425c63e72bc0c01d81bc7e9ba4bb41d11679e6.zip | |
Add branch predictions to complex math code
| -rw-r--r-- | ChangeLog | 24 | ||||
| -rw-r--r-- | math/s_catan.c | 7 | ||||
| -rw-r--r-- | math/s_catanf.c | 7 | ||||
| -rw-r--r-- | math/s_catanh.c | 15 | ||||
| -rw-r--r-- | math/s_catanhf.c | 15 | ||||
| -rw-r--r-- | math/s_catanhl.c | 15 | ||||
| -rw-r--r-- | math/s_catanl.c | 7 | ||||
| -rw-r--r-- | math/s_cexp.c | 17 | ||||
| -rw-r--r-- | math/s_cexpf.c | 17 | ||||
| -rw-r--r-- | math/s_cexpl.c | 17 | ||||
| -rw-r--r-- | math/s_clog.c | 7 | ||||
| -rw-r--r-- | math/s_clog10.c | 7 | ||||
| -rw-r--r-- | math/s_clog10f.c | 7 | ||||
| -rw-r--r-- | math/s_clog10l.c | 7 | ||||
| -rw-r--r-- | math/s_clogf.c | 6 | ||||
| -rw-r--r-- | math/s_clogl.c | 7 | ||||
| -rw-r--r-- | math/s_csqrt.c | 9 | ||||
| -rw-r--r-- | math/s_csqrtf.c | 9 | ||||
| -rw-r--r-- | math/s_csqrtl.c | 9 | ||||
| -rw-r--r-- | math/s_ctanf.c | 5 | ||||
| -rw-r--r-- | math/s_ctanh.c | 5 | ||||
| -rw-r--r-- | math/s_ctanhf.c | 5 | ||||
| -rw-r--r-- | math/s_ctanhl.c | 5 | ||||
| -rw-r--r-- | math/s_ctanl.c | 4 |
24 files changed, 101 insertions, 132 deletions
@@ -1,5 +1,29 @@ 2011-10-22 Ulrich Drepper <drepper@gmail.com> + * math/s_catan.c: Add branch predictions. + * math/s_catanf.c: Likewise. + * math/s_catanh.c: Likewise. + * math/s_catanhf.c: Likewise. + * math/s_catanhl.c: Likewise. + * math/s_catanl.c: Likewise. + * math/s_cexp.c: Likewise. + * math/s_cexpf.c: Likewise. + * math/s_cexpl.c: Likewise. + * math/s_clog.c: Likewise. + * math/s_clog10.c: Likewise. + * math/s_clog10f.c: Likewise. + * math/s_clog10l.c: Likewise. + * math/s_clogf.c: Likewise. + * math/s_clogl.c: Likewise. + * math/s_csqrt.c: Likewise. + * math/s_csqrtf.c: Likewise. + * math/s_csqrtl.c: Likewise. + * math/s_ctanf.c: Likewise. + * math/s_ctanh.c: Likewise. + * math/s_ctanhf.c: Likewise. + * math/s_ctanhl.c: Likewise. + * math/s_ctanl.c: Likewise. + * math/math_private.h: Define __nan, __nanf, __nanl. * math/s_cacosh.c: Include <math_private.h>. * math/s_cacoshl.c: Likewise. diff --git a/math/s_catan.c b/math/s_catan.c index 59c0a3af6b..1a458a3833 100644 --- a/math/s_catan.c +++ b/math/s_catan.c @@ -1,5 +1,5 @@ /* Return arc tangent of complex double value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __catan (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) { if (rcls == FP_INFINITE) { @@ -57,7 +56,7 @@ __catan (__complex__ double x) __imag__ res = __nan (""); } } - else if (rcls == FP_ZERO && icls == FP_ZERO) + else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { res = x; } diff --git a/math/s_catanf.c b/math/s_catanf.c index 0aefb6ef39..defcf18c67 100644 --- a/math/s_catanf.c +++ b/math/s_catanf.c @@ -1,5 +1,5 @@ /* Return arc tangent of complex float value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __catanf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) { if (rcls == FP_INFINITE) { @@ -57,7 +56,7 @@ __catanf (__complex__ float x) __imag__ res = __nanf (""); } } - else if (rcls == FP_ZERO && icls == FP_ZERO) + else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { res = x; } diff --git a/math/s_catanh.c b/math/s_catanh.c index 0b31b27708..22ade15fa8 100644 --- a/math/s_catanh.c +++ b/math/s_catanh.c @@ -1,5 +1,5 @@ /* Return arc hyperbole tangent for double value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __catanh (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) { if (icls == FP_INFINITE) { @@ -52,20 +51,18 @@ __catanh (__complex__ double x) __imag__ res = __nan (""); } } - else if (rcls == FP_ZERO && icls == FP_ZERO) + else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { res = x; } else { - double i2, num, den; - - i2 = __imag__ x * __imag__ x; + double i2 = __imag__ x * __imag__ x; - num = 1.0 + __real__ x; + double num = 1.0 + __real__ x; num = i2 + num * num; - den = 1.0 - __real__ x; + double den = 1.0 - __real__ x; den = i2 + den * den; __real__ res = 0.25 * (__ieee754_log (num) - __ieee754_log (den)); diff --git a/math/s_catanhf.c b/math/s_catanhf.c index 7424bda9b9..f3d07f2354 100644 --- a/math/s_catanhf.c +++ b/math/s_catanhf.c @@ -1,5 +1,5 @@ /* Return arc hyperbole tangent for float value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __catanhf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) { if (icls == FP_INFINITE) { @@ -52,20 +51,18 @@ __catanhf (__complex__ float x) __imag__ res = __nanf (""); } } - else if (rcls == FP_ZERO && icls == FP_ZERO) + else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { res = x; } else { - float i2, num, den; - - i2 = __imag__ x * __imag__ x; + float i2 = __imag__ x * __imag__ x; - num = 1.0 + __real__ x; + float num = 1.0 + __real__ x; num = i2 + num * num; - den = 1.0 - __real__ x; + float den = 1.0 - __real__ x; den = i2 + den * den; __real__ res = 0.25 * (__ieee754_logf (num) - __ieee754_logf (den)); diff --git a/math/s_catanhl.c b/math/s_catanhl.c index 9e67b8789c..af48f1a553 100644 --- a/math/s_catanhl.c +++ b/math/s_catanhl.c @@ -1,5 +1,5 @@ /* Return arc hyperbole tangent for long double value. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __catanhl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) { if (icls == FP_INFINITE) { @@ -52,20 +51,18 @@ __catanhl (__complex__ long double x) __imag__ res = __nanl (""); } } - else if (rcls == FP_ZERO && icls == FP_ZERO) + else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { res = x; } else { - long double i2, num, den; - - i2 = __imag__ x * __imag__ x; + long double i2 = __imag__ x * __imag__ x; - num = 1.0 + __real__ x; + long double num = 1.0 + __real__ x; num = i2 + num * num; - den = 1.0 - __real__ x; + long double den = 1.0 - __real__ x; den = i2 + den * den; __real__ res = 0.25 * (__ieee754_logl (num) - __ieee754_logl (den)); diff --git a/math/s_catanl.c b/math/s_catanl.c index b4ae321710..47df85cc7b 100644 --- a/math/s_catanl.c +++ b/math/s_catanl.c @@ -1,5 +1,5 @@ /* Return arc tangent of complex long double value. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __catanl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls <= FP_INFINITE || icls <= FP_INFINITE) + if (__builtin_expect (rcls <= FP_INFINITE || icls <= FP_INFINITE, 0)) { if (rcls == FP_INFINITE) { @@ -57,7 +56,7 @@ __catanl (__complex__ long double x) __imag__ res = __nanl (""); } } - else if (rcls == FP_ZERO && icls == FP_ZERO) + else if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { res = x; } diff --git a/math/s_cexp.c b/math/s_cexp.c index de122e07f8..0d1ec29850 100644 --- a/math/s_cexp.c +++ b/math/s_cexp.c @@ -1,5 +1,5 @@ /* Return value of complex exponential function for double complex value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -21,7 +21,6 @@ #include <complex.h> #include <fenv.h> #include <math.h> - #include <math_private.h> @@ -32,10 +31,10 @@ __cexp (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls >= FP_ZERO) + if (__builtin_expect (rcls >= FP_ZERO, 1)) { /* Real part is finite. */ - if (icls >= FP_ZERO) + if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ double exp_val = __ieee754_exp (__real__ x); @@ -61,15 +60,13 @@ __cexp (__complex__ double x) __real__ retval = __nan (""); __imag__ retval = __nan (""); -#ifdef FE_INVALID feraiseexcept (FE_INVALID); -#endif } } - else if (rcls == FP_INFINITE) + else if (__builtin_expect (rcls == FP_INFINITE, 1)) { /* Real part is infinite. */ - if (icls >= FP_ZERO) + if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ double value = signbit (__real__ x) ? 0.0 : HUGE_VAL; @@ -95,10 +92,8 @@ __cexp (__complex__ double x) __real__ retval = HUGE_VAL; __imag__ retval = __nan (""); -#ifdef FE_INVALID if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); -#endif } else { @@ -112,10 +107,8 @@ __cexp (__complex__ double x) __real__ retval = __nan (""); __imag__ retval = __nan (""); -#ifdef FE_INVALID if (rcls != FP_NAN || icls != FP_NAN) feraiseexcept (FE_INVALID); -#endif } return retval; diff --git a/math/s_cexpf.c b/math/s_cexpf.c index 70e4a02588..652fe3d5b2 100644 --- a/math/s_cexpf.c +++ b/math/s_cexpf.c @@ -1,5 +1,5 @@ /* Return value of complex exponential function for float complex value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -21,7 +21,6 @@ #include <complex.h> #include <fenv.h> #include <math.h> - #include <math_private.h> @@ -32,10 +31,10 @@ __cexpf (__complex__ float x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls >= FP_ZERO) + if (__builtin_expect (rcls >= FP_ZERO, 1)) { /* Real part is finite. */ - if (icls >= FP_ZERO) + if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ float exp_val = __ieee754_expf (__real__ x); @@ -61,15 +60,13 @@ __cexpf (__complex__ float x) __real__ retval = __nanf (""); __imag__ retval = __nanf (""); -#ifdef FE_INVALID feraiseexcept (FE_INVALID); -#endif } } - else if (rcls == FP_INFINITE) + else if (__builtin_expect (rcls == FP_INFINITE, 1)) { /* Real part is infinite. */ - if (icls >= FP_ZERO) + if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ float value = signbit (__real__ x) ? 0.0 : HUGE_VALF; @@ -95,10 +92,8 @@ __cexpf (__complex__ float x) __real__ retval = HUGE_VALF; __imag__ retval = __nanf (""); -#ifdef FE_INVALID if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); -#endif } else { @@ -112,10 +107,8 @@ __cexpf (__complex__ float x) __real__ retval = __nanf (""); __imag__ retval = __nanf (""); -#ifdef FE_INVALID if (rcls != FP_NAN || icls != FP_NAN) feraiseexcept (FE_INVALID); -#endif } return retval; diff --git a/math/s_cexpl.c b/math/s_cexpl.c index 1c585f8d0a..6bb56c02f5 100644 --- a/math/s_cexpl.c +++ b/math/s_cexpl.c @@ -1,5 +1,5 @@ /* Return value of complex exponential function for long double complex value. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -21,7 +21,6 @@ #include <complex.h> #include <fenv.h> #include <math.h> - #include <math_private.h> @@ -32,10 +31,10 @@ __cexpl (__complex__ long double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls >= FP_ZERO) + if (__builtin_expect (rcls >= FP_ZERO, 1)) { /* Real part is finite. */ - if (icls >= FP_ZERO) + if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ long double exp_val = __ieee754_expl (__real__ x); @@ -61,15 +60,13 @@ __cexpl (__complex__ long double x) __real__ retval = __nanl (""); __imag__ retval = __nanl (""); -#ifdef FE_INVALID feraiseexcept (FE_INVALID); -#endif } } - else if (rcls == FP_INFINITE) + else if (__builtin_expect (rcls == FP_INFINITE, 1)) { /* Real part is infinite. */ - if (icls >= FP_ZERO) + if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL; @@ -95,10 +92,8 @@ __cexpl (__complex__ long double x) __real__ retval = HUGE_VALL; __imag__ retval = __nanl (""); -#ifdef FE_INVALID if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); -#endif } else { @@ -112,10 +107,8 @@ __cexpl (__complex__ long double x) __real__ retval = __nanl (""); __imag__ retval = __nanl (""); -#ifdef FE_INVALID if (rcls != FP_NAN || icls != FP_NAN) feraiseexcept (FE_INVALID); -#endif } return retval; diff --git a/math/s_clog.c b/math/s_clog.c index 5e7b8fbdab..ba27140b4b 100644 --- a/math/s_clog.c +++ b/math/s_clog.c @@ -1,5 +1,5 @@ /* Compute complex natural logarithm. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,6 @@ #include <complex.h> #include <math.h> - #include <math_private.h> @@ -31,7 +30,7 @@ __clog (__complex__ double x) int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); - if (rcls == FP_ZERO && icls == FP_ZERO) + if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; @@ -39,7 +38,7 @@ __clog (__complex__ double x) /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } - else if (rcls != FP_NAN && icls != FP_NAN) + else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) { /* Neither real nor imaginary part is NaN. */ __real__ result = __ieee754_log (__ieee754_hypot (__real__ x, diff --git a/math/s_clog10.c b/math/s_clog10.c index a98de1942e..4b741fab55 100644 --- a/math/s_clog10.c +++ b/math/s_clog10.c @@ -1,5 +1,5 @@ /* Compute complex base 10 logarithm. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed |
