about summary refs log tree commit diff
path: root/math/s_cexpf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-10-22 13:17:30 -0400
committerUlrich Drepper <drepper@gmail.com>2011-10-22 13:17:30 -0400
commit77425c63e72bc0c01d81bc7e9ba4bb41d11679e6 (patch)
treec4fea5ed8070fc251140eba66b009bca1ff0e3b5 /math/s_cexpf.c
parentbc62c2fb152d6ffec63975d88fd8f1bc3d3b7c01 (diff)
downloadglibc-77425c63e72bc0c01d81bc7e9ba4bb41d11679e6.tar.gz
glibc-77425c63e72bc0c01d81bc7e9ba4bb41d11679e6.tar.xz
glibc-77425c63e72bc0c01d81bc7e9ba4bb41d11679e6.zip
Add branch predictions to complex math code
Diffstat (limited to 'math/s_cexpf.c')
-rw-r--r--math/s_cexpf.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/math/s_cexpf.c b/math/s_cexpf.c
index 70e4a02588..652fe3d5b2 100644
--- a/math/s_cexpf.c
+++ b/math/s_cexpf.c
@@ -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;