about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
Diffstat (limited to 'math')
-rw-r--r--math/math_private.h7
-rw-r--r--math/s_cacosh.c3
-rw-r--r--math/s_cacoshl.c3
-rw-r--r--math/s_casinh.c3
-rw-r--r--math/s_casinhf.c3
-rw-r--r--math/s_casinhl.c3
-rw-r--r--math/s_ccos.c48
-rw-r--r--math/s_ccosf.c48
-rw-r--r--math/s_ccosh.c24
-rw-r--r--math/s_ccoshf.c24
-rw-r--r--math/s_ccoshl.c26
-rw-r--r--math/s_ccosl.c48
-rw-r--r--math/s_csin.c12
-rw-r--r--math/s_csinf.c12
-rw-r--r--math/s_csinh.c26
-rw-r--r--math/s_csinhf.c26
-rw-r--r--math/s_csinhl.c26
-rw-r--r--math/s_csinl.c12
-rw-r--r--math/s_ctan.c4
19 files changed, 103 insertions, 255 deletions
diff --git a/math/math_private.h b/math/math_private.h
index db733c8ac7..4cb81ea418 100644
--- a/math/math_private.h
+++ b/math/math_private.h
@@ -395,4 +395,11 @@ extern void __docos (double __x, double __dx, double __v[]);
 #define libc_feupdateenvf(e) (void) feupdateenv (e)
 #define libc_feupdateenvl(e) (void) feupdateenv (e)
 
+#define __nan(str) \
+  (__builtin_constant_p (str) && str[0] == '\0' ? NAN : __nan (str))
+#define __nanf(str) \
+  (__builtin_constant_p (str) && str[0] == '\0' ? NAN : __nan (str))
+#define __nanl(str) \
+  (__builtin_constant_p (str) && str[0] == '\0' ? NAN : __nan (str))
+
 #endif /* _MATH_PRIVATE_H_ */
diff --git a/math/s_cacosh.c b/math/s_cacosh.c
index ada7ca5af6..bec6d3827e 100644
--- a/math/s_cacosh.c
+++ b/math/s_cacosh.c
@@ -1,5 +1,5 @@
 /* Return arc hyperbole cosine for double value.
-   Copyright (C) 1997, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2006, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -20,6 +20,7 @@
 
 #include <complex.h>
 #include <math.h>
+#include <math_private.h>
 
 
 __complex__ double
diff --git a/math/s_cacoshl.c b/math/s_cacoshl.c
index da23c8d8aa..36f7a5f70e 100644
--- a/math/s_cacoshl.c
+++ b/math/s_cacoshl.c
@@ -1,5 +1,5 @@
 /* Return arc hyperbole cosine for long double value.
-   Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2006, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -20,6 +20,7 @@
 
 #include <complex.h>
 #include <math.h>
+#include <math_private.h>
 
 
 __complex__ long double
diff --git a/math/s_casinh.c b/math/s_casinh.c
index a574add70e..db340ac1b1 100644
--- a/math/s_casinh.c
+++ b/math/s_casinh.c
@@ -1,5 +1,5 @@
 /* Return arc hyperbole sine 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,6 +20,7 @@
 
 #include <complex.h>
 #include <math.h>
+#include <math_private.h>
 
 
 __complex__ double
diff --git a/math/s_casinhf.c b/math/s_casinhf.c
index 7037ab937c..f545d8e2ee 100644
--- a/math/s_casinhf.c
+++ b/math/s_casinhf.c
@@ -1,5 +1,5 @@
 /* Return arc hyperbole sine 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,6 +20,7 @@
 
 #include <complex.h>
 #include <math.h>
+#include <math_private.h>
 
 
 __complex__ float
diff --git a/math/s_casinhl.c b/math/s_casinhl.c
index 376b2347a0..b8e3918290 100644
--- a/math/s_casinhl.c
+++ b/math/s_casinhl.c
@@ -1,5 +1,5 @@
 /* Return arc hyperbole sine 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,6 +20,7 @@
 
 #include <complex.h>
 #include <math.h>
+#include <math_private.h>
 
 
 __complex__ long double
diff --git a/math/s_ccos.c b/math/s_ccos.c
index 63851aab54..4612eb33c3 100644
--- a/math/s_ccos.c
+++ b/math/s_ccos.c
@@ -27,52 +27,12 @@
 __complex__ double
 __ccos (__complex__ double x)
 {
-  __complex__ double res;
+  __complex__ double y;
 
-  if (!isfinite (__real__ x) || __isnan (__imag__ x))
-    {
-      if (__real__ x == 0.0 || __imag__ x == 0.0)
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = 0.0;
+  __real__ y = -__imag__ x;
+  __imag__ y = __real__ x;
 
-#ifdef FE_INVALID
-	  if (__isinf_ns (__real__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-      else if (__isinf_ns (__imag__ x))
-	{
-	  __real__ res = HUGE_VAL;
-	  __imag__ res = __nan ("");
-
-#ifdef FE_INVALID
-	  if (__isinf_ns (__real__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-
-#ifdef FE_INVALID
-	  if (isfinite (__imag__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-    }
-  else
-    {
-      __complex__ double y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      res = __ccosh (y);
-    }
-
-  return res;
+  return __ccosh (y);
 }
 weak_alias (__ccos, ccos)
 #ifdef NO_LONG_DOUBLE
diff --git a/math/s_ccosf.c b/math/s_ccosf.c
index f0e9c2ac9e..1ee932486b 100644
--- a/math/s_ccosf.c
+++ b/math/s_ccosf.c
@@ -27,52 +27,12 @@
 __complex__ float
 __ccosf (__complex__ float x)
 {
-  __complex__ float res;
+  __complex__ float y;
 
-  if (!isfinite (__real__ x) || __isnanf (__imag__ x))
-    {
-      if (__real__ x == 0.0 || __imag__ x == 0.0)
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = 0.0;
+  __real__ y = -__imag__ x;
+  __imag__ y = __real__ x;
 
-#ifdef FE_INVALID
-	  if (__isinf_nsf (__real__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-      else if (__isinf_nsf (__imag__ x))
-	{
-	  __real__ res = HUGE_VALF;
-	  __imag__ res = __nanf ("");
-
-#ifdef FE_INVALID
-	  if (__isinf_nsf (__real__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-
-#ifdef FE_INVALID
-	  if (isfinite (__imag__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-    }
-  else
-    {
-      __complex__ float y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      res = __ccoshf (y);
-    }
-
-  return res;
+  return __ccoshf (y);
 }
 #ifndef __ccosf
 weak_alias (__ccosf, ccosf)
diff --git a/math/s_ccosh.c b/math/s_ccosh.c
index 83aa025d42..c10e5d899f 100644
--- a/math/s_ccosh.c
+++ b/math/s_ccosh.c
@@ -1,5 +1,5 @@
 /* Complex cosine 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 <drepper@cygnus.com>, 1997.
 
@@ -32,10 +32,10 @@ __ccosh (__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 sinh_val = __ieee754_sinh (__real__ x);
@@ -52,22 +52,14 @@ __ccosh (__complex__ double x)
 	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
 	  __real__ retval = __nan ("") + __nan ("");
 
-#ifdef FE_INVALID
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else if (rcls == FP_INFINITE)
     {
       /* Real part is infinite.  */
-      if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
-	}
-      else if (icls > FP_ZERO)
+      if (__builtin_expect (icls > FP_ZERO, 1))
 	{
 	  /* Imaginary part is finite.  */
 	  double sinix, cosix;
@@ -78,16 +70,20 @@ __ccosh (__complex__ double x)
 	  __imag__ retval = (__copysign (HUGE_VAL, sinix)
 			     * __copysign (1.0, __real__ x));
 	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = HUGE_VAL;
+	  __imag__ retval = __imag__ x * __copysign (1.0, __real__ 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
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 <drepper@cygnus.com>, 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.  */
diff --git a/math/s_ccoshl.c b/math/s_ccoshl.c
index 1913bb6ee4..ed1bc459df 100644
--- a/math/s_ccoshl.c
+++ b/math/s_ccoshl.c
@@ -1,5 +1,5 @@
 /* Complex cosine hyperbole function for long 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 <drepper@cygnus.com>, 1997.
 
@@ -32,10 +32,10 @@ __ccoshl (__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 sinh_val = __ieee754_sinhl (__real__ x);
@@ -52,22 +52,14 @@ __ccoshl (__complex__ long double x)
 	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl ("");
 	  __real__ retval = __nanl ("") + __nanl ("");
 
-#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_VALL;
-	  __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x);
-	}
-      else if (icls > FP_ZERO)
+      if (__builtin_expect (icls > FP_ZERO, 1))
 	{
 	  /* Imaginary part is finite.  */
 	  long double sinix, cosix;
@@ -78,16 +70,20 @@ __ccoshl (__complex__ long double x)
 	  __imag__ retval = (__copysignl (HUGE_VALL, sinix)
 			     * __copysignl (1.0, __real__ x));
 	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = HUGE_VALL;
+	  __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x);
+	}
       else
 	{
 	  /* The addition raises the invalid exception.  */
 	  __real__ retval = HUGE_VALL;
 	  __imag__ retval = __nanl ("") + __nanl ("");
 
-#ifdef FE_INVALID
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
diff --git a/math/s_ccosl.c b/math/s_ccosl.c
index 9902a02edd..153a60b08b 100644
--- a/math/s_ccosl.c
+++ b/math/s_ccosl.c
@@ -27,51 +27,11 @@
 __complex__ long double
 __ccosl (__complex__ long double x)
 {
-  __complex__ long double res;
+  __complex__ long double y;
 
-  if (!isfinite (__real__ x) || __isnanl (__imag__ x))
-    {
-      if (__real__ x == 0.0 || __imag__ x == 0.0)
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = 0.0;
+  __real__ y = -__imag__ x;
+  __imag__ y = __real__ x;
 
-#ifdef FE_INVALID
-	  if (__isinf_nsl (__real__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-      else if (__isinf_nsl (__imag__ x))
-	{
-	  __real__ res = HUGE_VALL;
-	  __imag__ res = __nanl ("");
-
-#ifdef FE_INVALID
-	  if (__isinf_nsl (__real__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-
-#ifdef FE_INVALID
-	  if (isfinite (__imag__ x))
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-    }
-  else
-    {
-      __complex__ long double y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      res = __ccoshl (y);
-    }
-
-  return res;
+  return __ccoshl (y);
 }
 weak_alias (__ccosl, ccosl)
diff --git a/math/s_csin.c b/math/s_csin.c
index 0d4441ca2b..07a78c4384 100644
--- a/math/s_csin.c
+++ b/math/s_csin.c
@@ -1,5 +1,5 @@
 /* Complex sine 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 <drepper@cygnus.com>, 1997.
 
@@ -35,10 +35,10 @@ __csin (__complex__ double x)
 
   __real__ x = fabs (__real__ x);
 
-  if (icls >= FP_ZERO)
+  if (__builtin_expect (icls >= FP_ZERO, 1))
     {
       /* Imaginary part is finite.  */
-      if (rcls >= FP_ZERO)
+      if (__builtin_expect (rcls >= FP_ZERO, 1))
 	{
 	  /* Real part is finite.  */
 	  double sinh_val = __ieee754_sinh (__imag__ x);
@@ -61,19 +61,15 @@ __csin (__complex__ double x)
 	      __real__ retval = __nan ("");
 	      __imag__ retval = __imag__ x;
 
-#ifdef FE_INVALID
 	      if (rcls == FP_INFINITE)
 		feraiseexcept (FE_INVALID);
-#endif
 	    }
 	  else
 	    {
 	      __real__ retval = __nan ("");
 	      __imag__ retval = __nan ("");
 
-#ifdef FE_INVALID
 	      feraiseexcept (FE_INVALID);
-#endif
 	    }
 	}
     }
@@ -107,10 +103,8 @@ __csin (__complex__ double x)
 	  __real__ retval = __nan ("");
 	  __imag__ retval = HUGE_VAL;
 
-#ifdef FE_INVALID
 	  if (rcls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
diff --git a/math/s_csinf.c b/math/s_csinf.c
index 61786ba6c8..4f4dfb8ea2 100644
--- a/math/s_csinf.c
+++ b/math/s_csinf.c
@@ -1,5 +1,5 @@
 /* Complex sine 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 <drepper@cygnus.com>, 1997.
 
@@ -35,10 +35,10 @@ __csinf (__complex__ float x)
 
   __real__ x = fabsf (__real__ x);
 
-  if (icls >= FP_ZERO)
+  if (__builtin_expect (icls >= FP_ZERO, 1))
     {
       /* Imaginary part is finite.  */
-      if (rcls >= FP_ZERO)
+      if (__builtin_expect (rcls >= FP_ZERO, 1))
 	{
 	  /* Real part is finite.  */
 	  float sinh_val = __ieee754_sinhf (__imag__ x);
@@ -61,19 +61,15 @@ __csinf (__complex__ float x)
 	      __real__ retval = __nanf ("");
 	      __imag__ retval = __imag__ x;
 
-#ifdef FE_INVALID
 	      if (rcls == FP_INFINITE)
 		feraiseexcept (FE_INVALID);
-#endif
 	    }
 	  else
 	    {
 	      __real__ retval = __nanf ("");
 	      __imag__ retval = __nanf ("");
 
-#ifdef FE_INVALID
 	      feraiseexcept (FE_INVALID);
-#endif
 	    }
 	}
     }
@@ -107,10 +103,8 @@ __csinf (__complex__ float x)
 	  __real__ retval = __nanf ("");
 	  __imag__ retval = HUGE_VALF;
 
-#ifdef FE_INVALID
 	  if (rcls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
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 <drepper@cygnus.com>, 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
diff --git a/math/s_csinhf.c b/math/s_csinhf.c
index 3440516529..51e837b14f 100644
--- a/math/s_csinhf.c
+++ b/math/s_csinhf.c
@@ -1,5 +1,5 @@
 /* Complex sine 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 <drepper@cygnus.com>, 1997.
 
@@ -35,10 +35,10 @@ __csinhf (__complex__ float x)
 
   __real__ x = fabsf (__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.  */
 	  float sinh_val = __ieee754_sinhf (__real__ x);
@@ -61,32 +61,22 @@ __csinhf (__complex__ float x)
 	      __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
 	      __imag__ retval = __nanf ("") + __nanf ("");
 
-#ifdef FE_INVALID
 	      if (icls == FP_INFINITE)
 		feraiseexcept (FE_INVALID);
-#endif
 	    }
 	  else
 	    {
 	      __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)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
-	  __imag__ retval = __imag__ x;
-	}
-      else if (icls > FP_ZERO)
+      if (__builtin_expect (icls > FP_ZERO, 1))
 	{
 	  /* Imaginary part is finite.  */
 	  float sinix, cosix;
@@ -99,6 +89,12 @@ __csinhf (__complex__ float x)
 	  if (negate)
 	    __real__ retval = -__real__ retval;
 	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
+	  __imag__ retval = __imag__ x;
+	}
       else
 	{
 	  /* The addition raises the invalid exception.  */
diff --git a/math/s_csinhl.c b/math/s_csinhl.c
index db1b47b301..d2964f8a2b 100644
--- a/math/s_csinhl.c
+++ b/math/s_csinhl.c
@@ -1,5 +1,5 @@
 /* Complex sine hyperbole function for long 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 <drepper@cygnus.com>, 1997.
 
@@ -35,10 +35,10 @@ __csinhl (__complex__ long double x)
 
   __real__ x = fabsl (__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.  */
 	  long double sinh_val = __ieee754_sinhl (__real__ x);
@@ -61,32 +61,22 @@ __csinhl (__complex__ long double x)
 	      __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
 	      __imag__ retval = __nanl ("") + __nanl ("");
 
-#ifdef FE_INVALID
 	      if (icls == FP_INFINITE)
 		feraiseexcept (FE_INVALID);
-#endif
 	    }
 	  else
 	    {
 	      __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)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = negate ? -HUGE_VALL : HUGE_VALL;
-	  __imag__ retval = __imag__ x;
-	}
-      else if (icls > FP_ZERO)
+      if (__builtin_expect (icls > FP_ZERO, 1))
 	{
 	  /* Imaginary part is finite.  */
 	  long double sinix, cosix;
@@ -99,6 +89,12 @@ __csinhl (__complex__ long double x)
 	  if (negate)
 	    __real__ retval = -__real__ retval;
 	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = negate ? -HUGE_VALL : HUGE_VALL;
+	  __imag__ retval = __imag__ x;
+	}
       else
 	{
 	  /* The addition raises the invalid exception.  */
diff --git a/math/s_csinl.c b/math/s_csinl.c
index 5e477eb7f9..300035c699 100644
--- a/math/s_csinl.c
+++ b/math/s_csinl.c
@@ -1,5 +1,5 @@
 /* Complex sine function for long 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 <drepper@cygnus.com>, 1997.
 
@@ -35,10 +35,10 @@ __csinl (__complex__ long double x)
 
   __real__ x = fabsl (__real__ x);
 
-  if (icls >= FP_ZERO)
+  if (__builtin_expect (icls >= FP_ZERO, 1))
     {
       /* Imaginary part is finite.  */
-      if (rcls >= FP_ZERO)
+      if (__builtin_expect (rcls >= FP_ZERO, 1))
 	{
 	  /* Real part is finite.  */
 	  long double sinh_val = __ieee754_sinhl (__imag__ x);
@@ -61,19 +61,15 @@ __csinl (__complex__ long double x)
 	      __real__ retval = __nanl ("");
 	      __imag__ retval = __imag__ x;
 
-#ifdef FE_INVALID
 	      if (rcls == FP_INFINITE)
 		feraiseexcept (FE_INVALID);
-#endif
 	    }
 	  else
 	    {
 	      __real__ retval = __nanl ("");
 	      __imag__ retval = __nanl ("");
 
-#ifdef FE_INVALID
 	      feraiseexcept (FE_INVALID);
-#endif
 	    }
 	}
     }
@@ -107,10 +103,8 @@ __csinl (__complex__ long double x)
 	  __real__ retval = __nanl ("");
 	  __imag__ retval = HUGE_VALL;
 
-#ifdef FE_INVALID
 	  if (rcls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
diff --git a/math/s_ctan.c b/math/s_ctan.c
index 0dd211e907..41958516f1 100644
--- a/math/s_ctan.c
+++ b/math/s_ctan.c
@@ -30,7 +30,7 @@ __ctan (__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 (__imag__ x))
 	{
@@ -46,10 +46,8 @@ __ctan (__complex__ double x)
 	  __real__ res = __nan ("");
 	  __imag__ res = __nan ("");
 
-#ifdef FE_INVALID
 	  if (__isinf_ns (__real__ x))
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else