about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-03-17 19:29:00 -0400
committerRich Felker <dalias@aerifal.cx>2012-03-17 19:29:00 -0400
commit316e024f63af0d0d2bb0df3dfce2620f4be827d1 (patch)
treec1dbe320f1034df38f293016f00f5bf7dc6f0128 /src
parent9cb6878e747909c7a45dd1c4dd550ac62e1f7690 (diff)
downloadmusl-316e024f63af0d0d2bb0df3dfce2620f4be827d1.tar.gz
musl-316e024f63af0d0d2bb0df3dfce2620f4be827d1.tar.xz
musl-316e024f63af0d0d2bb0df3dfce2620f4be827d1.zip
optimize x86 feclearexcept
if all exception flags will be cleared, we can avoid the expensive
store/reload of the environment and just use the fnclex instruction.
Diffstat (limited to 'src')
-rw-r--r--src/fenv/i386/fenv.s36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/fenv/i386/fenv.s b/src/fenv/i386/fenv.s
index 647b7961..e365b8f4 100644
--- a/src/fenv/i386/fenv.s
+++ b/src/fenv/i386/fenv.s
@@ -1,30 +1,34 @@
-2:	not %ecx
+.global feclearexcept
+.type feclearexcept,@function
+feclearexcept:	
+	mov 4(%esp),%ecx
+	not %ecx
+	test $0x3f,%ecx
+	jnz 2f
+1:	fnclex
+	xor %eax,%eax
+	ret
+2:	fnstsw %ax
+	and %ecx,%eax
+	jz 1b
 	sub $32,%esp
 	fnstenv (%esp)
-	and %ecx,4(%esp)
-	or %edx,4(%esp)
+	mov %al,4(%esp)
 	fldenv (%esp)
 	add $32,%esp
-	ret
-
-.global feclearexcept
-.type feclearexcept,@function
-feclearexcept:	
 	xor %eax,%eax
-	mov 4(%esp),%ecx
-	xor %edx,%edx
-	test %ecx,%ecx
-	jnz 2b
 	ret
 
 .global feraiseexcept
 .type feraiseexcept,@function
 feraiseexcept:	
+	mov 4(%esp),%eax
+	sub $32,%esp
+	fnstenv (%esp)
+	or %al,4(%esp)
+	fldenv (%esp)
+	add $32,%esp
 	xor %eax,%eax
-	mov 4(%esp),%edx
-	xor %ecx,%ecx
-	test %edx,%edx
-	jnz 2b
 	ret
 
 .global fesetround