diff options
author | Szabolcs Nagy <nsz@port70.net> | 2017-09-17 17:31:20 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2017-10-13 22:30:45 -0400 |
commit | 907476925fca05f24ebca5fcdc21f1e58ba7b313 (patch) | |
tree | 79aa3b08e17ed7e04d0ac53d612a62d43dbac3cc /src/misc | |
parent | b3516058eb9ff9e52a8720f0e5c0f6936cce6047 (diff) | |
download | musl-907476925fca05f24ebca5fcdc21f1e58ba7b313.tar.gz |
math: rewrite fma with mostly int arithmetics
the freebsd fma code failed to raise underflow exception in some
cases in nearest rounding mode (affects fmal too) e.g.
fma(-0x1p-1000, 0x1.000001p-74, 0x1p-1022)
and the inexact exception may be raised spuriously since the fenv
is not saved/restored around the exact multiplication algorithm
(affects x86 fma too).
another issue is that the underflow behaviour when the rounded result
is the minimal normal number is target dependent, ieee754 allows two
ways to raise underflow for inexact results: raise if the result before
rounding is in the subnormal range (e.g. aarch64, arm, powerpc) or if
the result after rounding with infinite exponent range is in the
subnormal range (e.g. x86, mips, sh).
to avoid all these issues the algorithm was rewritten with mostly int
arithmetics and float arithmetics is only used to get correct rounding
and raise exceptions according to the behaviour of the target without
any fenv.h dependency. it also unifies x86 and non-x86 fma.
fmaf is not affected, fmal need to be fixed too.
this algorithm depends on a_clz_64 and it required a few spurious
instructions to make sure underflow exception is raised in a particular
corner case. (normally FORCE_EVAL(tiny*tiny) would be used for this,
but on i386 gcc is broken if the expression is constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57245
and there is no easy portable fix for the macro.)
Diffstat (limited to 'src/misc')
0 files changed, 0 insertions, 0 deletions