about summary refs log tree commit diff
path: root/sysdeps/alpha/fpu/s_floorf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/alpha/fpu/s_floorf.c')
-rw-r--r--sysdeps/alpha/fpu/s_floorf.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/sysdeps/alpha/fpu/s_floorf.c b/sysdeps/alpha/fpu/s_floorf.c
index fd1ddab6be..8b421705cd 100644
--- a/sysdeps/alpha/fpu/s_floorf.c
+++ b/sysdeps/alpha/fpu/s_floorf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson.
 
@@ -20,37 +20,26 @@
 #include <math.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.  */
 
 float
 __floorf (float x)
 {
-  if (isless (fabsf (x), 16777216.0f))	/* 1 << FLT_MANT_DIG */
-    {
-      /* Note that Alpha S_Floating is stored in registers in a
-	 restricted T_Floating format, so we don't even need to
-	 convert back to S_Floating in the end.  The initial
-	 conversion to T_Floating is needed to handle denormals.  */
-
-      float tmp1, tmp2, new_x;
-
-      __asm ("cvtst/s %3,%2\n\t"
+  float two23 = copysignf (0x1.0p23, x);
+  float r, tmp;
+  
+  __asm (
 #ifdef _IEEE_FP_INEXACT
-	     "cvttq/svim %2,%1\n\t"
+	 "adds/suim %2, %3, %1\n\tsubs/suim %1, %3, %0"
 #else
-	     "cvttq/svm %2,%1\n\t"
+	 "adds/sum %2, %3, %1\n\tsubs/sum %1, %3, %0"
 #endif
-	     "cvtqt/m %1,%0\n\t"
-	     : "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
-	     : "f"(x));
-
-      /* floor(-0) == -0, and in general we'll always have the same
-	 sign as our input.  */
-      x = copysignf(new_x, x);
-    }
-  return x;
+	 : "=&f"(r), "=&f"(tmp)
+	 : "f"(x), "f"(two23));
+
+  /* floor(-0) == -0, and in general we'll always have the same
+     sign as our input.  */
+  return copysignf (r, x);
 }
 
 weak_alias (__floorf, floorf)