mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-23 06:32:05 +03:00
asm for hypot and hypotf
special care is made to avoid any inexact computations when either arg is zero (in which case the exact absolute value of the other arg should be returned) and to support the special condition that hypot(±inf,nan) yields inf. hypotl is not yet implemented since avoiding overflow is nontrivial.
This commit is contained in:
parent
a9e85c0a5c
commit
ad2d2b963a
45
src/math/i386/hypot.s
Normal file
45
src/math/i386/hypot.s
Normal file
@ -0,0 +1,45 @@
|
||||
.global hypot
|
||||
.type hypot,@function
|
||||
hypot:
|
||||
mov 8(%esp),%eax
|
||||
mov 16(%esp),%ecx
|
||||
add %eax,%eax
|
||||
add %ecx,%ecx
|
||||
and %eax,%ecx
|
||||
cmp $0xffe00000,%ecx
|
||||
jae 2f
|
||||
or 4(%esp),%eax
|
||||
jnz 1f
|
||||
fldl 12(%esp)
|
||||
fabs
|
||||
ret
|
||||
1: mov 16(%esp),%eax
|
||||
add %eax,%eax
|
||||
or 12(%esp),%eax
|
||||
jnz 1f
|
||||
fldl 4(%esp)
|
||||
fabs
|
||||
ret
|
||||
1: fldl 4(%esp)
|
||||
fld %st(0)
|
||||
fmulp
|
||||
fldl 12(%esp)
|
||||
fld %st(0)
|
||||
fmulp
|
||||
faddp
|
||||
fsqrt
|
||||
ret
|
||||
2: sub $0xffe00000,%eax
|
||||
or 4(%esp),%eax
|
||||
jnz 1f
|
||||
fldl 4(%esp)
|
||||
fabs
|
||||
ret
|
||||
1: mov 16(%esp),%eax
|
||||
add %eax,%eax
|
||||
sub $0xffe00000,%eax
|
||||
or 12(%esp),%eax
|
||||
fldl 12(%esp)
|
||||
jnz 1f
|
||||
fabs
|
||||
1: ret
|
42
src/math/i386/hypotf.s
Normal file
42
src/math/i386/hypotf.s
Normal file
@ -0,0 +1,42 @@
|
||||
.global hypotf
|
||||
.type hypotf,@function
|
||||
hypotf:
|
||||
mov 4(%esp),%eax
|
||||
mov 8(%esp),%ecx
|
||||
add %eax,%eax
|
||||
add %ecx,%ecx
|
||||
and %eax,%ecx
|
||||
cmp $0xff000000,%ecx
|
||||
jae 2f
|
||||
test %eax,%eax
|
||||
jnz 1f
|
||||
flds 8(%esp)
|
||||
fabs
|
||||
ret
|
||||
1: mov 8(%esp),%eax
|
||||
add %eax,%eax
|
||||
jnz 1f
|
||||
flds 4(%esp)
|
||||
fabs
|
||||
ret
|
||||
1: flds 4(%esp)
|
||||
fld %st(0)
|
||||
fmulp
|
||||
flds 8(%esp)
|
||||
fld %st(0)
|
||||
fmulp
|
||||
faddp
|
||||
fsqrt
|
||||
ret
|
||||
2: cmp $0xff000000,%eax
|
||||
jnz 1f
|
||||
flds 4(%esp)
|
||||
fabs
|
||||
ret
|
||||
1: mov 8(%esp),%eax
|
||||
add %eax,%eax
|
||||
cmp $0xff000000,%eax
|
||||
flds 8(%esp)
|
||||
jnz 1f
|
||||
fabs
|
||||
1: ret
|
Loading…
Reference in New Issue
Block a user