]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Optimization to some complex math functions
authorUlrich Drepper <drepper@gmail.com>
Sat, 22 Oct 2011 04:32:39 +0000 (00:32 -0400)
committerUlrich Drepper <drepper@gmail.com>
Sat, 22 Oct 2011 04:32:39 +0000 (00:32 -0400)
Also, change last reference to __sqrt into __sqrt to easily.

23 files changed:
ChangeLog
math/math_private.h
math/s_cacosh.c
math/s_cacoshl.c
math/s_casinh.c
math/s_casinhf.c
math/s_casinhl.c
math/s_ccos.c
math/s_ccosf.c
math/s_ccosh.c
math/s_ccoshf.c
math/s_ccoshl.c
math/s_ccosl.c
math/s_csin.c
math/s_csinf.c
math/s_csinh.c
math/s_csinhf.c
math/s_csinhl.c
math/s_csinl.c
math/s_ctan.c
sysdeps/ieee754/dbl-64/e_acosh.c
sysdeps/ieee754/flt-32/e_acoshf.c
sysdeps/ieee754/ldbl-96/e_acoshl.c

index 2a15d9c19af888ab38312a7e9d1beb3706c07070..adc9025a84d5ed14b6ca9f8d0f705e6b419be7fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2011-10-22  Ulrich Drepper  <drepper@gmail.com>
+
+       * math/math_private.h: Define __nan, __nanf, __nanl.
+       * math/s_cacosh.c: Include <math_private.h>.
+       * math/s_cacoshl.c: Likewise.
+       * math/s_casinh.c: Likewise.
+       * math/s_casinhf.c: Likewise.
+       * math/s_casinhl.c: Likewise.
+       * math/s_ccos.c: Rely entire on ccosh.
+       * math/s_ccosf.c: Rely entire on ccoshf.
+       * math/s_ccosl.c: Rely entirely on ccoshl.
+       * math/s_ccosh.c: Add branch predicion helpers.  Add branch prediction.
+       Remove tests for FE_INVALID.
+       * math/s_ccoshf.c: Likewise.
+       * math/s_ccoshl.c: Likewise.
+       * math/s_csin.c: Likewise.
+       * math/s_csinf.c: Likewise.
+       * math/s_csinh.c Likewise.
+       * math/s_csinhf.c: Likewise.
+       * math/s_csinhl.c: Likewise.
+       * math/s_csinl.c: Likewise.
+       * math/s_ctan.c: Likewise.
+       * sysdeps/ieee754/dbl-64/e_acosh.c: Use __ieee754_sqrt.
+       * sysdeps/ieee754/flt-32/e_acoshf.c: Use __ieee754_sqrtf.
+       * sysdeps/ieee754/ldbl-96/e_acoshl.c: Use __ieee754_sqrtl.
+
 2011-10-21  Ulrich Drepper  <drepper@gmail.com>
 
        * sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): Fix
index db733c8ac7e42d93cd8b07637f23777796cf0d33..4cb81ea41829ce65275585e5f9a2e915537addc5 100644 (file)
@@ -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_ */
index ada7ca5af6163a903cc831e3ad56949afda59920..bec6d3827e2179f8b239cb79e6fbd5cdb1897106 100644 (file)
@@ -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
index da23c8d8aaa27c9a82e90bc98d09cfd5c23befa6..36f7a5f70e135be99ca640097b2ce15f454a9981 100644 (file)
@@ -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
index a574add70e0a552ce540a8115689dae4e77225fb..db340ac1b1e78ac3fa6519f4946af27955faaf59 100644 (file)
@@ -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
index 7037ab937c9e71cc0b0d832271c74469fd588524..f545d8e2ee3a9ad4cc026270c94d61d72229d1a9 100644 (file)
@@ -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
index 376b2347a085cda61259858579bac645a1588224..b8e391829053fc135fdcb6ae9af516c15cdc7dea 100644 (file)
@@ -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
index 63851aab5488c700b082a995b66c9ed59b45916c..4612eb33c347e5b47274f89b7491e6597139d950 100644 (file)
 __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
index f0e9c2ac9ef99195c96dc81f46e92206dd370360..1ee932486bc0c7f2e573ae70005c259e01dab0eb 100644 (file)
 __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)
index 83aa025d42066a65b568e67033b39118f42df6ed..c10e5d899f6536840885af9f26344de9b2305fa4 100644 (file)
@@ -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
index b9b2f3346f36e7fd760f0a76c5267b3a0f542a65..6aae5d854beaa13189ed9559acfe62039166ea14 100644 (file)
@@ -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.  */
index 1913bb6ee47f836b7412a57e9fa3240011b6181f..ed1bc459dfb261ef92a328b0c78aaf5aa1f225aa 100644 (file)
@@ -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
index 9902a02edd2363dfee91c6a02b4e996d620d7606..153a60b08b95290f8850f1a641fc1f26e2ccdc5f 100644 (file)
 __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)
index 0d4441ca2bc923bbb813487fa129daf681c8dfb2..07a78c43841329b1b8adbc3db1bfd02af29c2e7d 100644 (file)
@@ -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
index 61786ba6c85c82e297089b1985a6ae711dc0073e..4f4dfb8ea291b237924732e0d5edcc16a7a52d9b 100644 (file)
@@ -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
index 138d80505e08adbec9f02e0f7118ea7f50691532..2eec065a8f7d0a20f16e007c55a11cd604c66ba9 100644 (file)
@@ -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
index 34405165294ae484cc14f46ddcbfae1ee5307111..51e837b14fa4c42fc80d799ce00c7e755bb7c8a7 100644 (file)
@@ -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.  */
index db1b47b301796575a614dcc88d6d47eb4d233688..d2964f8a2b6995bd2dd4261070da75c994066a05 100644 (file)
@@ -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.  */
index 5e477eb7f9725fecd78f2af5814650c3f11daec4..300035c69935475fde84e68fe67c66fcb6e5bfad 100644 (file)
@@ -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
index 0dd211e9076630db7b8ed20ecb709c3b4ba1a9bf..41958516f193779052d2e107e04a94f996189eec 100644 (file)
@@ -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
index f474e9ab5c6c558e1a95457e9d46318be4d172f7..6ef10cb84b5d2167c3921e74dd20b00412752337 100644 (file)
@@ -52,7 +52,7 @@ __ieee754_acosh(double x)
            return __ieee754_log(2.0*x-one/(x+__ieee754_sqrt(t-one)));
        } else {                        /* 1<x<2 */
            t = x-one;
-           return __log1p(t+__sqrt(2.0*t+t*t));
+           return __log1p(t+__ieee754_sqrt(2.0*t+t*t));
        }
 }
 strong_alias (__ieee754_acosh, __acosh_finite)
index db8f6ec462be12c78dcb18149e58d3abf50313d1..777e0b9e361c35e03f46a1841cd0913bc258002c 100644 (file)
@@ -52,7 +52,7 @@ ln2   = 6.9314718246e-01;  /* 0x3f317218 */
            return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one)));
        } else {                        /* 1<x<2 */
            t = x-one;
-           return __log1pf(t+__sqrtf((float)2.0*t+t*t));
+           return __log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t));
        }
 }
 strong_alias (__ieee754_acoshf, __acoshf_finite)
index 6f709b7bdf63e6f7b4deab889a4a2b1d6b5258b4..29004ec267c71bf5f10acaaf4a16f98f31d5c340 100644 (file)
@@ -55,7 +55,7 @@ __ieee754_acoshl(long double x)
            return __ieee754_logl(2.0*x-one/(x+__ieee754_sqrtl(t-one)));
        } else {                        /* 1<x<2 */
            t = x-one;
-           return __log1pl(t+__sqrtl(2.0*t+t*t));
+           return __log1pl(t+__ieee754_sqrtl(2.0*t+t*t));
        }
 }
 strong_alias (__ieee754_acoshl, __acoshl_finite)