diff options
author | Szabolcs Nagy <nsz@port70.net> | 2020-01-18 17:55:25 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-02-21 23:42:05 -0500 |
commit | b3797d3b2e10e6fff2a6b04af917e61e95838b08 (patch) | |
tree | 31e7b1858b566167f4303bbeab58d6074549e321 /src/internal/libm.h | |
parent | 040c1d16b468c50c04fc94edff521f1637708328 (diff) | |
download | musl-b3797d3b2e10e6fff2a6b04af917e61e95838b08.tar.gz musl-b3797d3b2e10e6fff2a6b04af917e61e95838b08.tar.bz2 musl-b3797d3b2e10e6fff2a6b04af917e61e95838b08.tar.xz musl-b3797d3b2e10e6fff2a6b04af917e61e95838b08.zip |
math: fix __rem_pio2 in non-nearest rounding modes
Handle when after reduction |y| > pi/4+tiny. This happens in directed
rounding modes because the fast round to int code does not give the
nearest integer. In such cases the reduction may not be symmetric
between x and -x so e.g. cos(x)==cos(-x) may not hold (but polynomial
evaluation is not symmetric either with directed rounding so fixing
that would require more changes with bigger performance impact).
The fix only adds two predictable branches in nearest rounding mode,
simple ubenchmark does not show relevant performance regression in
nearest rounding mode.
The code could be improved: e.g reducing the medium size threshold
such that two step reduction is enough instead of three, and the
single precision case can avoid the issue by doing the round to int
differently, but this fix was kept minimal.
Diffstat (limited to 'src/internal/libm.h')
0 files changed, 0 insertions, 0 deletions