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_ccoshf.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'math/s_ccoshf.c') diff --git a/math/s_ccoshf.c b/math/s_ccoshf.c index b9b2f3346f..6aae5d854b 100644 --- a/math/s_ccoshf.c +++ b/math/s_ccoshf.c @@ -1,5 +1,5 @@ /* Complex cosine hyperbole function for float. - 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. @@ -32,10 +32,10 @@ __ccoshf (__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 sinh_val = __ieee754_sinhf (__real__ x); @@ -52,22 +52,14 @@ __ccoshf (__complex__ float x) __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf (""); __real__ retval = __nanf (""); -#ifdef FE_INVALID if (icls == FP_INFINITE) 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) - { - /* Imaginary part is 0.0. */ - __real__ retval = HUGE_VALF; - __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x); - } - else if (icls > FP_ZERO) + if (__builtin_expect (icls > FP_ZERO, 1)) { /* Imaginary part is finite. */ float sinix, cosix; @@ -78,6 +70,12 @@ __ccoshf (__complex__ float x) __imag__ retval = (__copysignf (HUGE_VALF, sinix) * __copysignf (1.0, __real__ x)); } + else if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = HUGE_VALF; + __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x); + } else { /* The addition raises the invalid exception. */ -- cgit 1.4.1