Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/x86_64/gen PR/44293: Paul Goyette: Fix the mes...
details: https://anonhg.NetBSD.org/src/rev/86b5565265d6
branches: trunk
changeset: 770016:86b5565265d6
user: christos <christos%NetBSD.org@localhost>
date: Fri Sep 30 17:42:34 2011 +0000
description:
PR/44293: Paul Goyette: Fix the mess of the rounding code.
diffstat:
lib/libc/arch/x86_64/gen/flt_rounds.S | 10 ++++++----
lib/libc/arch/x86_64/gen/fpgetround.S | 9 ++++-----
lib/libc/arch/x86_64/gen/fpsetround.S | 34 ++++++++++++++--------------------
3 files changed, 24 insertions(+), 29 deletions(-)
diffs (102 lines):
diff -r c3c01b3149c7 -r 86b5565265d6 lib/libc/arch/x86_64/gen/flt_rounds.S
--- a/lib/libc/arch/x86_64/gen/flt_rounds.S Fri Sep 30 15:47:20 2011 +0000
+++ b/lib/libc/arch/x86_64/gen/flt_rounds.S Fri Sep 30 17:42:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: flt_rounds.S,v 1.5 2011/09/29 22:55:45 christos Exp $ */
+/* $NetBSD: flt_rounds.S,v 1.6 2011/09/30 17:42:34 christos Exp $ */
#include <machine/asm.h>
@@ -12,8 +12,10 @@
_ALIGN_TEXT
ENTRY(__flt_rounds)
fnstcw -4(%rsp)
- movl -4(%rsp), %eax
- shrl $10, %eax
+ movl -4(%rsp), %ecx
+ shrl $9, %ecx
+ andl $6, %ecx
+ movl $0x2d, %eax /* 0x2d = 00.10.11.01 */
+ sarl %cl, %eax /* 0,1,2,3 -> 1,3,2,0 */
andl $3, %eax
- xorl $1, %eax /* map 0,1,2,3 -> 1,0,3,2 */
ret
diff -r c3c01b3149c7 -r 86b5565265d6 lib/libc/arch/x86_64/gen/fpgetround.S
--- a/lib/libc/arch/x86_64/gen/fpgetround.S Fri Sep 30 15:47:20 2011 +0000
+++ b/lib/libc/arch/x86_64/gen/fpgetround.S Fri Sep 30 17:42:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpgetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
+/* $NetBSD: fpgetround.S,v 1.4 2011/09/30 17:42:34 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
@@ -8,7 +8,7 @@
#include <machine/asm.h>
/*
- * XXX store only x87 state. If an application only uses the fp*
+ * XXX load only x87 state. If an application only uses the fp*
* interface, this should be in sync with the SSE mxcsr register.
*/
@@ -19,7 +19,6 @@
ENTRY(fpgetround)
#endif
fnstcw -4(%rsp)
- movl -4(%rsp),%eax
- rorl $10,%eax
- andl $3,%eax
+ movl -4(%rsp), %eax
+ andl $0x00000c00, %eax
ret
diff -r c3c01b3149c7 -r 86b5565265d6 lib/libc/arch/x86_64/gen/fpsetround.S
--- a/lib/libc/arch/x86_64/gen/fpsetround.S Fri Sep 30 15:47:20 2011 +0000
+++ b/lib/libc/arch/x86_64/gen/fpsetround.S Fri Sep 30 17:42:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $ */
+/* $NetBSD: fpsetround.S,v 1.4 2011/09/30 17:42:34 christos Exp $ */
/*
* Written by Frank van der Linden at Wasabi Systems for NetBSD.
@@ -21,28 +21,22 @@
#else
ENTRY(fpsetround)
#endif
- fnstcw -4(%rsp)
- stmxcsr -8(%rsp)
-
- andl $3,%edi
- movl -4(%rsp),%edx
- rorl $10,%edx
- movl %edx,%eax
- andl $3,%eax
+ fnstcw -4(%rsp)
+ movl -4(%rsp), %edx
+ movl %edx, %eax
+ andl $0x00000c00, %eax
+ andl $0xfffff3ff, %edx
+ orl %edi, %edx
+ movl %edx, -4(%rsp)
+ fldcw -4(%rsp)
- andl $~3,%edx
+ stmxcsr -4(%rsp)
+ movl -4(%rsp), %edx
+ andl $0xffff9fff, %edx
+ sall $3, %edi
orl %edi,%edx
- roll $10,%edx
movl %edx,-4(%rsp)
+ ldmxcsr -4(%rsp)
- movl -8(%rsp),%edx
- rorl $13,%edx
- andl $~3,%edx
- orl %edi,%edx
- roll $13,%edx
- movl %edx,-8(%rsp)
-
- ldmxcsr -8(%rsp)
- fldcw -4(%rsp)
ret
Home |
Main Index |
Thread Index |
Old Index