Add branch predictions to complex math code

This commit is contained in:
Ulrich Drepper 2011-10-22 13:17:30 -04:00
parent bc62c2fb15
commit 77425c63e7
24 changed files with 101 additions and 132 deletions

View File

@ -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.

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
double i2 = __imag__ x * __imag__ x;
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));

View File

@ -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;
float i2 = __imag__ x * __imag__ x;
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));

View File

@ -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;
long double i2 = __imag__ x * __imag__ x;
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));

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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 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 @@ __clog10 (__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 @@ __clog10 (__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_log10 (__ieee754_hypot (__real__ x,

View File

@ -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 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 @@ __clog10f (__complex__ float 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 @@ __clog10f (__complex__ float x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsf (__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_log10f (__ieee754_hypotf (__real__ x,

View File

@ -1,5 +1,5 @@
/* Compute complex base 10 logarithm.
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 @@ __clog10l (__complex__ long 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_PIl : 0.0;
@ -39,7 +38,7 @@ __clog10l (__complex__ long double x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsl (__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_log10l (__ieee754_hypotl (__real__ x,

View File

@ -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.
@ -31,7 +31,7 @@ __clogf (__complex__ float 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 +39,7 @@ __clogf (__complex__ float x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsf (__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_logf (__ieee754_hypotf (__real__ x,

View File

@ -1,5 +1,5 @@
/* Compute complex natural logarithm.
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 @@ __clogl (__complex__ long 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_PIl : 0.0;
@ -39,7 +38,7 @@ __clogl (__complex__ long double x)
/* Yes, the following line raises an exception. */
__real__ result = -1.0 / fabsl (__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_logl (__ieee754_hypotl (__real__ x,

View File

@ -1,5 +1,5 @@
/* Complex square root of double value.
Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -21,7 +21,6 @@
#include <complex.h>
#include <math.h>
#include <math_private.h>
@ -32,7 +31,7 @@ __csqrt (__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)
{
@ -61,7 +60,7 @@ __csqrt (__complex__ double x)
}
else
{
if (icls == FP_ZERO)
if (__builtin_expect (icls == FP_ZERO, 0))
{
if (__real__ x < 0.0)
{
@ -75,7 +74,7 @@ __csqrt (__complex__ double x)
__imag__ res = __copysign (0.0, __imag__ x);
}
}
else if (rcls == FP_ZERO)
else if (__builtin_expect (rcls == FP_ZERO, 0))
{
double r = __ieee754_sqrt (0.5 * fabs (__imag__ x));

View File

@ -1,5 +1,5 @@
/* Complex square root of float value.
Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -21,7 +21,6 @@
#include <complex.h>
#include <math.h>
#include <math_private.h>
@ -32,7 +31,7 @@ __csqrtf (__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)
{
@ -61,7 +60,7 @@ __csqrtf (__complex__ float x)
}
else
{
if (icls == FP_ZERO)
if (__builtin_expect (icls == FP_ZERO, 0))
{
if (__real__ x < 0.0)
{
@ -75,7 +74,7 @@ __csqrtf (__complex__ float x)
__imag__ res = __copysignf (0.0, __imag__ x);
}
}
else if (rcls == FP_ZERO)
else if (__builtin_expect (rcls == FP_ZERO, 0))
{
float r = __ieee754_sqrtf (0.5 * fabsf (__imag__ x));

View File

@ -1,5 +1,5 @@
/* Complex square root of long double value.
Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -21,7 +21,6 @@
#include <complex.h>
#include <math.h>
#include <math_private.h>
@ -32,7 +31,7 @@ __csqrtl (__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)
{
@ -61,7 +60,7 @@ __csqrtl (__complex__ long double x)
}
else
{
if (icls == FP_ZERO)
if (__builtin_expect (icls == FP_ZERO, 0))
{
if (__real__ x < 0.0)
{
@ -75,7 +74,7 @@ __csqrtl (__complex__ long double x)
__imag__ res = __copysignl (0.0, __imag__ x);
}
}
else if (rcls == FP_ZERO)
else if (__builtin_expect (rcls == FP_ZERO, 0))
{
long double r = __ieee754_sqrtl (0.5 * fabsl (__imag__ x));

View File

@ -21,7 +21,6 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include <math_private.h>
@ -30,7 +29,7 @@ __ctanf (__complex__ float x)
{
__complex__ float res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
if (__isinf_nsf (__imag__ x))
{
@ -46,10 +45,8 @@ __ctanf (__complex__ float x)
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
#ifdef FE_INVALID
if (__isinf_nsf (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else

View File

@ -21,7 +21,6 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include <math_private.h>
@ -30,7 +29,7 @@ __ctanh (__complex__ double x)
{
__complex__ double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
if (__isinf_ns (__real__ x))
{
@ -46,10 +45,8 @@ __ctanh (__complex__ double x)
__real__ res = __nan ("");
__imag__ res = __nan ("");
#ifdef FE_INVALID
if (__isinf_ns (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else

View File

@ -21,7 +21,6 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include <math_private.h>
@ -30,7 +29,7 @@ __ctanhf (__complex__ float x)
{
__complex__ float res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
if (__isinf_nsf (__real__ x))
{
@ -46,10 +45,8 @@ __ctanhf (__complex__ float x)
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
#ifdef FE_INVALID
if (__isinf_nsf (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else

View File

@ -21,7 +21,6 @@
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include <math_private.h>
@ -30,7 +29,7 @@ __ctanhl (__complex__ long double x)
{
__complex__ long double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
if (__isinf_nsl (__real__ x))
{
@ -46,10 +45,8 @@ __ctanhl (__complex__ long double x)
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
#ifdef FE_INVALID
if (__isinf_nsl (__imag__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else

View File

@ -30,7 +30,7 @@ __ctanl (__complex__ long double x)
{
__complex__ long double res;
if (!isfinite (__real__ x) || !isfinite (__imag__ x))
if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0))
{
if (__isinf_nsl (__imag__ x))
{
@ -46,10 +46,8 @@ __ctanl (__complex__ long double x)
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
#ifdef FE_INVALID
if (__isinf_nsl (__real__ x))
feraiseexcept (FE_INVALID);
#endif
}
}
else