Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <e5a4695c-2333-f496-88ab-51b2241696e6@mail.com>
Date: Sat, 23 Feb 2019 09:21:08 -0500
From: Shane Seelig <stseelig@...l.com>
To: musl@...ts.openwall.com
Subject: x87 asin and acos

Currently 'asin' uses the algorithm:
	arcsin(x) == arctan(x/(sqrt((1-x)(1+x))))
If the following algorithm were to be used instead, an 'fadd' could be
removed.
	arcsin(x) == arctan(x/(sqrt(1-x**2)))


current:
	fldx	X(%esp)		# %st(0) = x

	fld 	%st(0)		# %st(1) = x
				# %st(0) = x

	fld1			# %st(2) = x
				# %st(1) = x
				# %st(0) = 1
	# unixware bug
	fsub	%st(0),%st(1)	# %st(2) = x
				# %st(1) = 1-x
				# %st(0) = 1

	fadd	%st(2), %st(0)	# %st(2) = x
				# %st(1) = 1-x
				# %st(0) = 1+x

	fmulp	%st(0), %st(1)	# %st(1) = x
				# %st(0) = 1-x**2

	fsqrt			# %st(1) = x
				# %st(0) = sqrt(1-x**2)

	fpatan			# %st(0) = arcsin(x)

	ret


new:
	fldx	X(%esp)		# %st(0) = x

	fld	%st(0)		# %st(1) = x
				# %st(0) = x

	fmul	%st(0), %st(0)	# %st(1) = x
				# %st(0) = x**2

	fld1			# %st(2) = x
				# %st(1) = x**2
				# %st(0) = 1
	# unixware bug
	fsubp	%st(0), %st(1)	# %st(1) = x
				# %st(0) = 1-x**2

	fsqrt			# %st(1) = x
				# %st(0) = sqrt(1-x**2)

	fpatan			# %st(0) = arcsin(x)

	ret


affected files:
	math/i386/acos.s
	math/i386/asin.s
	math/x32/acosl.s
	math/x32/asinl.s
	math/x86_64/acosl.s
	math/x86_64/asinl.s

Please CC me.

--

Shane

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.