From bc62c2fb152d6ffec63975d88fd8f1bc3d3b7c01 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 22 Oct 2011 00:32:39 -0400 Subject: Optimization to some complex math functions Also, change last reference to __sqrt into __sqrt to easily. --- math/s_csinh.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'math/s_csinh.c') diff --git a/math/s_csinh.c b/math/s_csinh.c index 138d80505e..2eec065a8f 100644 --- a/math/s_csinh.c +++ b/math/s_csinh.c @@ -1,5 +1,5 @@ /* Complex sine hyperbole function for double. - 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 , 1997. @@ -35,10 +35,10 @@ __csinh (__complex__ double x) __real__ x = fabs (__real__ 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 sinh_val = __ieee754_sinh (__real__ x); @@ -61,32 +61,22 @@ __csinh (__complex__ double x) __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); __imag__ retval = __nan ("") + __nan (""); -#ifdef FE_INVALID if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); -#endif } else { __real__ retval = __nan (""); __imag__ retval = __nan (""); -#ifdef FE_INVALID feraiseexcept (FE_INVALID); -#endif } } } else if (rcls == FP_INFINITE) { /* Real part is infinite. */ - if (icls == FP_ZERO) - { - /* Imaginary part is 0.0. */ - __real__ retval = negate ? -HUGE_VAL : HUGE_VAL; - __imag__ retval = __imag__ x; - } - else if (icls > FP_ZERO) + if (__builtin_expect (icls > FP_ZERO, 1)) { /* Imaginary part is finite. */ double sinix, cosix; @@ -99,16 +89,20 @@ __csinh (__complex__ double x) if (negate) __real__ retval = -__real__ retval; } + else if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = negate ? -HUGE_VAL : HUGE_VAL; + __imag__ retval = __imag__ x; + } else { /* The addition raises the invalid exception. */ __real__ retval = HUGE_VAL; __imag__ retval = __nan ("") + __nan (""); -#ifdef FE_INVALID if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); -#endif } } else -- cgit v1.2.1