diff options
Diffstat (limited to 'sysdeps/alpha/fpu/s_floor.c')
-rw-r--r-- | sysdeps/alpha/fpu/s_floor.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/sysdeps/alpha/fpu/s_floor.c b/sysdeps/alpha/fpu/s_floor.c index b22c52303d..5af6386155 100644 --- a/sysdeps/alpha/fpu/s_floor.c +++ b/sysdeps/alpha/fpu/s_floor.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson. @@ -21,32 +21,26 @@ #include <math_ldbl_opt.h> -/* Use the -inf rounding mode conversion instructions to implement - floor. We note when the exponent is large enough that the value - must be integral, as this avoids unpleasant integer overflows. */ +/* Use the -inf rounding mode conversion instructions to implement floor. */ double __floor (double x) { - if (isless (fabs (x), 9007199254740992.0)) /* 1 << DBL_MANT_DIG */ - { - double tmp1, new_x; - - __asm ( + double two52 = copysign (0x1.0p52, x); + double r, tmp; + + __asm ( #ifdef _IEEE_FP_INEXACT - "cvttq/svim %2,%1\n\t" + "addt/suim %2, %3, %1\n\tsubt/suim %1, %3, %0" #else - "cvttq/svm %2,%1\n\t" + "addt/sum %2, %3, %1\n\tsubt/sum %1, %3, %0" #endif - "cvtqt/m %1,%0\n\t" - : "=f"(new_x), "=&f"(tmp1) - : "f"(x)); - - /* floor(-0) == -0, and in general we'll always have the same - sign as our input. */ - x = copysign(new_x, x); - } - return x; + : "=&f"(r), "=&f"(tmp) + : "f"(x), "f"(two52)); + + /* floor(-0) == -0, and in general we'll always have the same + sign as our input. */ + return copysign (r, x); } weak_alias (__floor, floor) |