about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2014-07-03 08:52:45 -0700
committerRichard Henderson <rth@twiddle.net>2014-07-03 08:52:45 -0700
commitca7b945c7330064f494436611bd35fce6107abf6 (patch)
tree5176ca06cbb59eea5a267269df6812736eb29a24
parentcd1175a373590f053bea8aa9f2dfaeae13906aa9 (diff)
downloadglibc-ca7b945c7330064f494436611bd35fce6107abf6.tar.gz
glibc-ca7b945c7330064f494436611bd35fce6107abf6.tar.xz
glibc-ca7b945c7330064f494436611bd35fce6107abf6.zip
alpha: Fix lround implementations
Use chopped rounding to add 0.5.
-rw-r--r--ChangeLog3
-rw-r--r--sysdeps/alpha/fpu/s_lround.c8
-rw-r--r--sysdeps/alpha/fpu/s_lroundf.c8
3 files changed, 11 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 87b7a9385c..017003e241 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2014-07-03  Richard Henderson  <rth@redhat.com>
 
+	* sysdeps/alpha/fpu/s_lround.c: Add 0.5 with chopped rounding.
+	* sysdeps/alpha/fpu/s_lroundf.c: Likewise.
+
 	* sysdeps/alpha/fpu/s_round.c: Remove file.
 	* sysdeps/alpha/fpu/s_roundf.c: Remove file.
 
diff --git a/sysdeps/alpha/fpu/s_lround.c b/sysdeps/alpha/fpu/s_lround.c
index dedb98e31a..52a88b6b56 100644
--- a/sysdeps/alpha/fpu/s_lround.c
+++ b/sysdeps/alpha/fpu/s_lround.c
@@ -25,11 +25,11 @@
 long int
 __lround (double x)
 {
-  double adj;
+  double adj, y;
 
-  adj = 0x1.fffffffffffffp-2;	/* nextafter (0.5, 0.0) */
-  adj = copysign (adj, x);
-  return x + adj;
+  adj = copysign (0.5, x);
+  asm("addt/suc %1,%2,%0" : "=&f"(y) : "f"(x), "f"(adj));
+  return y;
 }
 
 strong_alias (__lround, __llround)
diff --git a/sysdeps/alpha/fpu/s_lroundf.c b/sysdeps/alpha/fpu/s_lroundf.c
index 650004dbc1..ebbb1295a4 100644
--- a/sysdeps/alpha/fpu/s_lroundf.c
+++ b/sysdeps/alpha/fpu/s_lroundf.c
@@ -25,11 +25,11 @@
 long int
 __lroundf (float x)
 {
-  float adj;
+  float adj, y;
 
-  adj = 0x1.fffffep-2;		/* nextafterf (0.5f, 0.0f) */
-  adj = copysignf (adj, x);
-  return x + adj;
+  adj = copysignf (0.5f, x);
+  asm("adds/suc %1,%2,%0" : "=&f"(y) : "f"(x), "f"(adj));
+  return y;
 }
 
 strong_alias (__lroundf, __llroundf)