about summary refs log tree commit diff
path: root/src/fenv/x86_64
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-08-18 15:34:07 +0000
committerSzabolcs Nagy <nsz@port70.net>2013-08-18 16:27:21 +0000
commitd8764bf84022397ff9d22310f78fcd78d801e2bf (patch)
tree289574d06451582fd67b5cde646cd6bfd368fa66 /src/fenv/x86_64
parentbaba2630c9cf778b41e218dfa980fcfdbec808e6 (diff)
downloadmusl-d8764bf84022397ff9d22310f78fcd78d801e2bf.tar.gz
musl-d8764bf84022397ff9d22310f78fcd78d801e2bf.tar.xz
musl-d8764bf84022397ff9d22310f78fcd78d801e2bf.zip
optimize x86 feclearexcept: only use save/restore x87 fenv if needed
the x87 exception summary (ES) and stack fault (SF) flags may be
spuriously cleared by feclearexcept using the fnclex instruction,
but these flags are not observable through libc hence maintaining
their state is not critical.
Diffstat (limited to 'src/fenv/x86_64')
-rw-r--r--src/fenv/x86_64/fenv.s26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/fenv/x86_64/fenv.s b/src/fenv/x86_64/fenv.s
index c48dade3..dda6b61a 100644
--- a/src/fenv/x86_64/fenv.s
+++ b/src/fenv/x86_64/fenv.s
@@ -1,25 +1,21 @@
 .global feclearexcept
 .type feclearexcept,@function
 feclearexcept:
+		# maintain exceptions in the sse mxcsr, clear x87 exceptions
 	mov %edi,%ecx
+	fnstsw %ax
+	test %eax,%ecx
+	jz 1f
+	fnclex
+1:	stmxcsr -8(%rsp)
+	and $0x3f,%eax
+	or %eax,-8(%rsp)
+	test %ecx,-8(%rsp)
+	jz 1f
 	not %ecx
-	stmxcsr -8(%rsp)
 	and %ecx,-8(%rsp)
 	ldmxcsr -8(%rsp)
-	test $0x3f,%ecx
-	jnz 2f
-1:	fnclex
-	xor %eax,%eax
-	ret
-2:	fnstsw %ax
-	and %ecx,%eax
-	jz 1b
-	sub $32,%rsp
-	fnstenv (%rsp)
-	mov %al,4(%rsp)
-	fldenv (%rsp)
-	add $32,%rsp
-	xor %eax,%eax
+1:	xor %eax,%eax
 	ret
 
 .global feraiseexcept