Commit Graph

971 Commits

Author SHA1 Message Date
nsz
b03255af77 fix remainder*.c: remove useless long double cast 2012-03-19 23:39:47 +01:00
nsz
4caa17b2a1 don't try to create non-standard denormalization signal
Underflow exception is only raised when the result is
invalid, but fmod is always exact. x87 has a denormalization
exception, but that's nonstandard. And the superflous *1.0
will be optimized away by any compiler that does not honor
signaling nans.
2012-03-19 23:30:45 +01:00
Rich Felker
0108420281 Merge remote branch 'nsz/master' 2012-03-19 18:30:35 -04:00
nsz
75483499da new modff.c code, fix nan handling in modfl 2012-03-19 23:27:45 +01:00
nsz
2786c7d216 use scalbn or *2.0 instead of ldexp, fix fmal
Some code assumed ldexp(x, 1) is faster than 2.0*x,
but ldexp is a wrapper around scalbn which uses
multiplications inside, so this optimization is
wrong.

This commit also fixes fmal which accidentally
used ldexp instead of ldexpl loosing precision.

There are various additional changes from the
work-in-progress const cleanups.
2012-03-19 22:57:58 +01:00
nsz
01fdfd491b fix long double const workaround in cbrtl 2012-03-19 22:49:03 +01:00
nsz
2e8c8fbe7d don't inline __rem_pio2l so the code size is smaller 2012-03-19 19:26:31 +01:00
nsz
c3587effe2 minor fix in __tanl (get sign properly) 2012-03-19 19:14:32 +01:00
Rich Felker
d9c1d72cdc bug fix: wrong opcode for writing long long 2012-03-19 13:58:47 -04:00
nsz
eca1c35e5b remove long double const workarounds
Some long double consts were stored in two doubles as a workaround
for x86_64 and i386 with the following comment:
/* Long double constants are slow on these arches, and broken on i386. */
This is most likely old gcc bug related to the default x87 fpu
precision setting (it's double instead of double extended on BSD).
2012-03-19 18:52:17 +01:00
nsz
9a810cb685 fix erfl wrapper for long double==double case 2012-03-19 18:06:06 +01:00
Rich Felker
b04b588791 asm for log1p 2012-03-19 10:59:41 -04:00
Rich Felker
9d82a15e15 asm for log2 2012-03-19 10:43:28 -04:00
Rich Felker
27deb53889 asm for remquo
this could perhaps use some additional testing for corner cases, but
it seems to be correct.
2012-03-19 09:42:51 -04:00
Rich Felker
02db27d9de optimize exponential asm for i386
up to 30% faster exp2 by avoiding slow frndint and fscale functions.
expm1 also takes a much more direct path for small arguments (the
expected usage case).
2012-03-19 09:00:30 -04:00
Rich Felker
da7458a602 Merge remote branch 'nsz/master' 2012-03-19 06:28:22 -04:00
Rich Felker
be5b01f855 fix broken modf family functions 2012-03-19 06:22:54 -04:00
Rich Felker
1bf4dad327 asm for modf functions 2012-03-19 05:56:41 -04:00
nsz
8051e08e10 simplify scalbn*.c implementations
The old scalbn.c was wrong and slow, the new one is just slow.
(scalbn(0x1p+1023,-2097) should give 0x1p-1074, but the old code gave 0)
2012-03-19 10:54:07 +01:00
nsz
f767aba8af Merge branch 'master' of git://git.etalabs.net/musl 2012-03-19 10:50:42 +01:00
Rich Felker
0b70a1e9a9 asm for floor/ceil/trunc 2012-03-19 05:42:04 -04:00
nsz
9322344fa4 Merge branch 'master' of git://git.etalabs.net/musl 2012-03-19 10:20:24 +01:00
Rich Felker
58ff9e8eaf asm for scalbn family
unlike some implementations, these functions perform the equivalent of
gcc's -ffloat-store on the result before returning. this is necessary
to raise underflow/overflow/inexact exceptions, perform the correct
rounding with denormals, etc.
2012-03-19 05:15:30 -04:00
Rich Felker
bc33e61704 asm for inverse trig functions
unlike trig functions, these are easy to do in asm because they do not
involve (arbitrary-precision) argument reduction. fpatan automatically
takes care of domain issues, and in asin and acos, fsqrt takes care of
them for us.
2012-03-19 04:56:07 -04:00
nsz
0627e58af8 Merge branch 'master' of git://git.etalabs.net/musl 2012-03-19 08:01:21 +01:00
Rich Felker
495a52ae7b asm for log functions 2012-03-18 23:50:54 -04:00
Rich Felker
aa1b4dff45 fix broken exponential asm
infinities were getting converted into nans. the new code simply tests
for infinity and replaces it with a large magnitude value of the same
sign.

also, the fcomi instruction is apparently not part of the i387
instruction set, so avoid using it.
2012-03-18 23:17:28 -04:00
Rich Felker
37eb14dd2b asm for lrint family on i386 2012-03-18 22:05:20 -04:00
nsz
dbdec9722e Merge branch 'master' of git://git.etalabs.net/musl 2012-03-19 02:55:31 +01:00
Rich Felker
6f26cf3dac asm exponential functions for i386 2012-03-18 21:43:43 -04:00
nsz
682e471400 remove unnecessary TODO comments from fma.c 2012-03-19 02:05:57 +01:00
nsz
d09a83f613 fmal bug fix: nan input should not raise exception 2012-03-19 00:59:16 +01:00
nsz
b1cbd70743 add fma implementation for x86
correctly rounded double precision fma using extended
precision arithmetics for ld80 systems (x87)
2012-03-19 00:36:55 +01:00
Rich Felker
b935147761 assembly optimizations for fmod/remainder functions 2012-03-18 17:09:34 -04:00
Rich Felker
8d9e948652 asm versions of some simple math functions for i386 and x86_64
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-18 16:43:54 -04:00
nsz
afad262440 simplify lround and llround functions
Simple wrappers around round is enough because
spurious inexact exception is allowed.
2012-03-18 20:52:33 +01:00
nsz
65db00983f make lrint and llrint functions work without fenv support 2012-03-18 20:40:43 +01:00
nsz
9b6899f2c5 faster lrint and llrint functions
A faster workaround for spurious inexact exceptions
when the result cannot be represented. The old code
actually could be wrong, because gcc reordered the
integer conversion and the exception check.
2012-03-18 19:27:39 +01:00
Rich Felker
9e2a895aaa fix loads of missing const in new libm, and some global vars (?!) in powl 2012-03-18 01:58:28 -04:00
Rich Felker
8e092217dd move nonstandard gamma() etc. to _GNU_SOURCE only
it's not even provided in the library at the moment, but could easily
be provided with weak aliases if desired.
2012-03-17 21:48:48 -04:00
Rich Felker
65db6bf5ea c++ seems to want some casts in the float representation-access macros 2012-03-17 21:40:10 -04:00
Rich Felker
da0acc32ef release notes for 0.8.7 2012-03-17 20:35:25 -04:00
Rich Felker
b60053e762 try fixing/optimizing x86_64 fenv exception code
untested; may need followup-fixes.
2012-03-17 20:10:02 -04:00
Rich Felker
316e024f63 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.
2012-03-17 19:29:00 -04:00
Rich Felker
9cb6878e74 fix x86_64 fe[gs]etround, analogous to nsz's x86 changes 2012-03-17 18:02:20 -04:00
Rich Felker
d5e576c752 minor 387 fenv optimizations 2012-03-17 17:49:10 -04:00
Rich Felker
0b337e04aa Merge remote branch 'nsz/master' 2012-03-17 17:34:30 -04:00
nsz
88cfaf8a14 fix i386 fegetround and make fesetround faster
Note that the new fesetround has slightly different semantics:

Storing the floating-point environment with fnstenv makes the
next fldenv (or fldcw) "non-signaling", so unmasked and pending
exceptions does not invoke the exception handler.
(These are rare since exceptions are handled immediately and by
default all exceptions are masked anyway. But if one manually
unmasks an exception in the control word then either sets the
corresponding exception flag in the status word or the execution
of an exception raising floating-point operation gets interrupted
then it may happen).
So the old implementation did not trap in some rare cases
where the new implementation traps.

However POSIX does not specify anything like the x87 exception
handling traps and the fnstenv/fldenv pair is significantly slower
than the fnstcw/fldcw pair (new code is about 5x faster here and
it's dominated by the function call overhead).
2012-03-17 13:46:15 +01:00
Rich Felker
523a3ab1a2 don't fail on inability to install dynamic linker (e.g. if not root) 2012-03-17 00:48:55 -04:00
Rich Felker
d3fc724759 one more fenv availability issue: lround 2012-03-17 00:02:36 -04:00