]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/e_scalbl.c
Improve __ieee754_exp() performance by greater than 5x on sparc/x86.
[thirdparty/glibc.git] / math / e_scalbl.c
index 256e7b131f9c749a4bac39fce419b072715cd83c..64c7765adb83ca1bb317fd69ca3888f581b1f288 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2014 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
 
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -26,10 +25,7 @@ __attribute__ ((noinline))
 invalid_fn (long double x, long double fn)
 {
   if (__rintl (fn) != fn)
-    {
-      feraiseexcept (FE_INVALID);
-      return __nan ("");
-    }
+    return (fn - fn) / (fn - fn);
   else if (fn > 65000.0L)
     return __scalbnl (x, 65000);
   else
@@ -40,17 +36,17 @@ invalid_fn (long double x, long double fn)
 long double
 __ieee754_scalbl (long double x, long double fn)
 {
-  if (__builtin_expect (__isnanl (x), 0))
+  if (__glibc_unlikely (isnan (x)))
     return x * fn;
-  if (__builtin_expect (!__finitel (fn), 0))
+  if (__glibc_unlikely (!isfinite (fn)))
     {
-      if (__isnanl (fn) || fn > 0.0L)
+      if (isnan (fn) || fn > 0.0L)
        return x * fn;
       if (x == 0.0L)
        return x;
       return x / -fn;
     }
-  if (__builtin_expect ((long double) (int) fn != fn, 0))
+  if (__glibc_unlikely (fabsl (fn) >= 0x1p31L || (long double) (int) fn != fn))
     return invalid_fn (x, fn);
 
   return __scalbnl (x, (int) fn);