summaryrefslogtreecommitdiff
path: root/src/math/x86_64
AgeCommit message (Collapse)AuthorFilesLines
2014-11-05math: use fnstsw consistently instead of fstsw in x87 asmSzabolcs Nagy2-2/+2
fnstsw does not wait for pending unmasked x87 floating-point exceptions and it is the same as fstsw when all exceptions are masked which is the only environment libc supports.
2014-11-05math: fix x86_64 and x32 asm not to use sahf instructionSzabolcs Nagy3-14/+7
Some early x86_64 cpus (released before 2006) did not support sahf/lahf instructions so they should be avoided (intel manual says they are only supported if CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 1). The workaround simplifies exp2l and expm1l because fucomip can be used instead of the fucomp;fnstsw;sahf sequence copied from i386. In fmodl and remainderl sahf is replaced by a simple bit test.
2013-09-13fix x86_64 lrintl asm, againRich Felker1-2/+2
the underlying problem was not incorrect sign extension (fixed in the previous commit to this file by nsz) but that code that treats "long" as 32-bit was copied blindly from i386 to x86_64. now lrintl is identical to llrintl on x86_64, as it should be.
2013-09-05math: fix expm1l on x86_64 (avoid underflow for large negative x)Szabolcs Nagy3-3/+13
copy the fix from i386: return -1 instead of exp2l(x)-1 when x <= -65
2013-09-05math: fix lrintl.s on x86_64 (use movslq to signextend the result)Szabolcs Nagy1-1/+1
2013-09-05math: fix exp2l asm on x86 (raise underflow correctly)Szabolcs Nagy1-35/+40
there were two problems: * omitted underflow on subnormal results: exp2l(-16383.5) was calculated as sqrt(2)*2^-16384, the last bits of sqrt(2) are zero so the down scaling does not underflow eventhough the result is in subnormal range * spurious underflow for subnormal inputs: exp2l(0x1p-16400) was evaluated as f2xm1(x)+1 and f2xm1 raised underflow (because inexact subnormal result) the first issue is fixed by raising underflow manually if x is in (-32768,-16382] and not integer (x-0x1p63+0x1p63 != x) the second issue is fixed by treating x in (-0x1p64,0x1p64) specially for these fixes the special case handling was completely rewritten
2013-08-16fix build of x86_64 expl assemblyRich Felker1-1/+1
apparently this label change was not carried over when adapting the changes from the i386 version.
2013-08-15math: fix x86 expl.s to raise underflow and clean up special case handlingSzabolcs Nagy1-22/+15
2012-12-16math: x86_64 version of expl, fixed some comments in the i386 versionSzabolcs Nagy1-0/+108
2012-12-16math: move x86_64 exp2l implementation to exp2l.s from expl.sSzabolcs Nagy3-85/+76
2012-12-12math: add empty __invtrigl.s to i386 and x86_64Szabolcs Nagy1-0/+0
__invtrigl is not needed when acosl, asinl, atanl have asm implementations
2012-08-08math: fix exp.s on i386 and x86_64 so the exception flags are correctnsz1-19/+17
exp(inf), exp(-inf), exp(nan) used to raise wrong flags
2012-06-02use fistpll mnemonic instead of fistpq (more widely supported) on x86_64 tooRich Felker1-1/+1
this was fixed previously on i386 but the corresponding code on x86_64 was missed.
2012-05-05math: change the formula used for acos.snsz1-10/+8
old: 2*atan2(sqrt(1-x),sqrt(1+x)) new: atan2(fabs(sqrt((1-x)*(1+x))),x) improvements: * all edge cases are fixed (sign of zero in downward rounding) * a bit faster (here a single call is about 131ns vs 162ns) * a bit more precise (at most 1ulp error on 1M uniform random samples in [0,1), the old formula gave some 2ulp errors as well)
2012-04-29fix typo in the x86_64 rounding asmRich Felker4-4/+4
2012-04-29new math asm (abs/rounding) for x86_64Rich Felker6-0/+36
untested
2012-04-04math: fix x86 asin accuracynsz1-3/+3
use (1-x)*(1+x) instead of (1-x*x) in asin.s the later can be inaccurate with upward rounding when x is close to 1
2012-03-29math: remove x86 modf asmnsz1-27/+0
the int part was wrong when -1 < x <= -0 (+0.0 instead of -0.0) and the size and performace gain of the asm version was negligible
2012-03-22acos.s fix: use the formula acos(x) = atan2(sqrt(1-x),sqrt(1+x))nsz1-3/+1
the old formula atan2(1,sqrt((1+x)/(1-x))) was faster but could give nan result at x=1 when the rounding mode is FE_DOWNWARD (so 1-1 == -0 and 2/-0 == -inf), the new formula gives -0 at x=+-1 with downward rounding.
2012-03-20x86_64 math asm, long double functions onlyRich Felker17-0/+239
this has not been tested heavily, but it's known to at least assemble and run in basic usage cases. it's nearly identical to the corresponding i386 code, and thus expected to be just as correct or just as incorrect.
2012-03-18assembly optimizations for fmod/remainder functionsRich Felker2-0/+22
2012-03-18asm versions of some simple math functions for i386 and x86_64Rich Felker2-0/+12
these are functions that have direct fpu approaches to implementation without problematic exception or rounding issues. x86_64 lacks float/double versions because i'm unfamiliar with the necessary sse code for performing these operations.
2012-03-13first commit of the new libm!Rich Felker3-0/+5
thanks to the hard work of Szabolcs Nagy (nsz), identifying the best (from correctness and license standpoint) implementations from freebsd and openbsd and cleaning them up! musl should now fully support c99 float and long double math functions, and has near-complete complex math support. tgmath should also work (fully on gcc-compatible compilers, and mostly on any c99 compiler). based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from nsz's libm git repo, with some additions (dummy versions of a few missing long double complex functions, etc.) by me. various cleanups still need to be made, including re-adding (if they're correct) some asm functions that were dropped.
2011-06-26type directives for x86_64 math asmRich Felker2-0/+2
2011-02-15Port musl to x86-64. One giant commit!Nicholas J. Kain2-0/+6