math: move x87-family rint functions to C with inline asm
[musl] / src / math / i386 / acos.s
index bfff0c5..af423a2 100644 (file)
@@ -1,30 +1,18 @@
-.global acosf
-.type acosf,@function
-acosf:
-       flds 4(%esp)
-       jmp 1f
-
-.global acosl
-.type acosl,@function
-acosl:
-       fldt 4(%esp)
-       jmp 1f
+# use acos(x) = atan2(fabs(sqrt((1-x)*(1+x))), x)
 
 .global acos
 .type acos,@function
 acos:
        fldl 4(%esp)
-1:     fld1
-       fld %st(1)
+       fld %st(0)
        fld1
-       fsubp
-       fsqrt
-       fxch %st(2)
-       faddp
+       fsub %st(0),%st(1)
+       fadd %st(2)
+       fmulp
        fsqrt
+       fabs         # fix sign of zero (matters in downward rounding mode)
+       fxch %st(1)
        fpatan
-       fld1
-       fld1
-       faddp
-       fmulp
+       fstpl 4(%esp)
+       fldl 4(%esp)
        ret