summaryrefslogtreecommitdiff
path: root/math/w_powf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-10-12 11:27:51 -0400
committerUlrich Drepper <drepper@gmail.com>2011-10-12 11:27:51 -0400
commit0ac5ae2335292908f39031b1ea9fe8edce433c0f (patch)
treef9d26c8abc0de39d18d4c13e70f6022cdc6b461f /math/w_powf.c
parenta843a204a3e8a0dd53584dad3668771abaec84ac (diff)
Optimize libm
libm is now somewhat integrated with gcc's -ffinite-math-only option and lots of the wrapper functions have been optimized.
Diffstat (limited to 'math/w_powf.c')
-rw-r--r--math/w_powf.c122
1 files changed, 60 insertions, 62 deletions
diff --git a/math/w_powf.c b/math/w_powf.c
index 761e4d1328..c0406f4c12 100644
--- a/math/w_powf.c
+++ b/math/w_powf.c
@@ -1,77 +1,75 @@
-/* w_powf.c -- float version of w_pow.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $";
-#endif
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
-/*
- * wrapper powf(x,y) return x**y
- */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
#include <math.h>
#include <math_private.h>
-#ifdef __STDC__
- float __powf(float x, float y) /* wrapper powf */
-#else
- float __powf(x,y) /* wrapper powf */
- float x,y;
-#endif
+/* wrapper powf */
+float
+__powf (float x, float y)
{
-#ifdef _IEEE_LIBM
- return __ieee754_powf(x,y);
-#else
- float z;
- z=__ieee754_powf(x,y);
- if(_LIB_VERSION == _IEEE_|| __isnanf(y)) return z;
- if(__isnanf(x)) {
- if(y==(float)0.0)
- /* powf(NaN,0.0) */
- return (float)__kernel_standard((double)x,(double)y,142);
- else
- return z;
- }
- if(x==(float)0.0) {
- if(y==(float)0.0)
- /* powf(0.0,0.0) */
- return (float)__kernel_standard((double)x,(double)y,120);
- if(__finitef(y)&&y<(float)0.0) {
- if (signbit (x) && signbit (z))
- /* powf(0.0,negative) */
- return (float)__kernel_standard((double)x,(double)y,123);
+ float z = __ieee754_powf (x, y);
+ if (__builtin_expect (!__finitef (z), 0))
+ {
+ if (_LIB_VERSION != _IEEE_)
+ {
+ if (__isnanf (x))
+ {
+ if (y == 0.0f)
+ /* pow(NaN,0.0) */
+ return __kernel_standard_f (x, y, 142);
+ }
+ else if (__finitef (x) && __finitef (y))
+ {
+ if (__isnanf (z))
+ /* pow neg**non-int */
+ return __kernel_standard_f (x, y, 124);
+ else if (x == 0.0f && y < 0.0f)
+ {
+ if (signbit (x) && signbit (z))
+ /* pow(-0.0,negative) */
+ return __kernel_standard_f (x, y, 123);
+ else
+ /* pow(+0.0,negative) */
+ return __kernel_standard_f (x, y, 143);
+ }
else
- return (float)__kernel_standard((double)x,(double)y,143);
+ /* pow overflow */
+ return __kernel_standard_f (x, y, 121);
}
- return z;
}
- if(!__finitef(z)) {
- if(__finitef(x)&&__finitef(y)) {
- if(__isnanf(z))
- /* powf neg**non-int */
- return (float)__kernel_standard((double)x,(double)y,124);
- else
- /* powf overflow */
- return (float)__kernel_standard((double)x,(double)y,121);
- }
+ }
+ else if (__builtin_expect (z == 0.0f, 0) && __finitef (x) && __finitef (y)
+ && _LIB_VERSION != _IEEE_)
+ {
+ if (x == 0.0f)
+ {
+ if (y == 0.0f)
+ /* pow(0.0,0.0) */
+ return __kernel_standard_f (x, y, 120);
}
- if(z==(float)0.0&&__finitef(x)&&__finitef(y))
- /* powf underflow */
- return (float)__kernel_standard((double)x,(double)y,122);
- return z;
-#endif
+ else
+ /* pow underflow */
+ return __kernel_standard_f (x, y, 122);
+ }
+
+ return z;
}
weak_alias (__powf, powf)