Implement tanf function correctly rounded for all rounding modes.
We use the range reduction that is shared with `sinf`, `cosf`, and `sincosf`:
```
k = round(x * 32/pi) and y = x * (32/pi) - k.
```
Then we use the tangent of sum formula:
```
tan(x) = tan((k + y)* pi/32) = tan((k mod 32) * pi / 32 + y * pi/32)
= (tan((k mod 32) * pi/32) + tan(y * pi/32)) / (1 - tan((k mod 32) * pi/32) * tan(y * pi/32))
```
We need to make a further reduction when `k mod 32 >= 16` due to the pole at `pi/2` of `tan(x)` function:
```
if (k mod 32 >= 16): k = k - 31, y = y - 1.0
```
And to compute the final result, we store `tan(k * pi/32)` for `k = -15..15` in a table of 32 double values,
and evaluate `tan(y * pi/32)` with a degree-11 minimax odd polynomial generated by Sollya with:
```
> P = fpminimax(tan(y * pi/32)/y, [|0, 2, 4, 6, 8, 10|], [|D...|], [0, 1.5]);
```
Performance benchmark using `perf` tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf
CORE-MATH reciprocal throughput : 18.586
System LIBC reciprocal throughput : 50.068
LIBC reciprocal throughput : 33.823
LIBC reciprocal throughput : 25.161 (with `-msse4.2` flag)
LIBC reciprocal throughput : 19.157 (with `-mfma` flag)
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf --latency
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency : 55.630
System LIBC latency : 106.264
LIBC latency : 96.060
LIBC latency : 90.727 (with `-msse4.2` flag)
LIBC latency : 82.361 (with `-mfma` flag)
```
Reviewed By: orex
Differential Revision: https://reviews.llvm.org/D131715
Change sinf/cosf range reduction to mod pi/32 to be shared with tanf,
since polynomial approximations for tanf on subintervals of length pi/16 do not
provide enough accuracy.
Reviewed By: orex
Differential Revision: https://reviews.llvm.org/D131652
Add "using" and "status" sections to the sidebar to make getting these
easier.
Fixed mobile formatting not overflow left and right.
Tested:
Chrome on Desktop, using mobile restrictions in devtools.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D131369
This design is borrowed from the lldb folks (thank you!) to declutter
the page.
* The version number at the top is removed.
* Links are pushed over to a sidebar
* The sidebar has headings
There are other minor changes:
* The warning about this project not being ready is now an RST "warning"
* Links to the Bug Reports and the Source Code are Added
* Refer to this project as either "The LLVM C LIbrary" or "The libc"
Tested:
Built locally
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D131242
New exp2 function algorithm:
1) Improved performance: 8.176 vs 15.270 by core-math perf tool.
2) Improved accuracy. Only two special values left.
3) Lookup table size reduced twice.
Differential Revision: https://reviews.llvm.org/D129005
Change `sinf` range reduction to mod pi/16 to be shared with `cosf`.
Previously, `sinf` used range reduction `mod pi`, but this cannot be used to implement `cosf` since the minimax algorithm for `cosf` does not converge due to critical points at `pi/2`. In order to be able to share the same range reduction functions for both `sinf` and `cosf`, we change the range reduction to `mod pi/16` for the following reasons:
- The table size is sufficiently small: 32 entries for `sin(k * pi/16)` with `k = 0..31`. It could be reduced to 16 entries if we treat the final sign separately, with an extra multiplication at the end.
- The polynomials' degrees are reduced to 7/8 from 15, with extra computations to combine `sin` and `cos` with trig sum equality.
- The number of exceptional cases reduced to 2 (with FMA) and 3 (without FMA).
- The latency is reduced while maintaining similar throughput as before.
Reviewed By: zimmermann6
Differential Revision: https://reviews.llvm.org/D130629
This is a implementation of find remainder fmod function from standard libm.
The underline algorithm is developed by myself, but probably it was first
invented before.
Some features of the implementation:
1. The code is written on more-or-less modern C++.
2. One general implementation for both float and double precision numbers.
3. Spitted platform/architecture dependent and independent code and tests.
4. Tests covers 100% of the code for both float and double numbers. Tests cases with NaN/Inf etc is copied from glibc.
5. The new implementation in general 2-4 times faster for “regular” x,y values. It can be 20 times faster for x/y huge value, but can also be 2 times slower for double denormalized range (according to perf tests provided).
6. Two different implementation of division loop are provided. In some platforms division can be very time consuming operation. Depend on platform it can be 3-10 times slower than multiplication.
Performance tests:
The test is based on core-math project (https://gitlab.inria.fr/core-math/core-math). By Tue Ly suggestion I took hypot function and use it as template for fmod. Preserving all test cases.
`./check.sh <--special|--worst> fmodf` passed.
`CORE_MATH_PERF_MODE=rdtsc ./perf.sh fmodf` results are
```
GNU libc version: 2.35
GNU libc release: stable
21.166 <-- FPU
51.031 <-- current glibc
37.659 <-- this fmod version.
```
Rewrite the introduction of the page to state clearly the goals of
LLVM's libc project.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D127174
This patch adds a document describing the status of the string functions
in LLVM-libc.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D123823
A section briefly mentioning the planned future enhancements has also
been included.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D123761
This patch adds a document describing the status of the string functions
in LLVM-libc.
Reviewed By: sivachandra, jeffbailey
Differential Revision: https://reviews.llvm.org/D123645
The prior page was the proposal doc, this one is now
more about what the project intends to do, written in the
present tense.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119379
The LLVM Libc project is no longer just a proposal and should have
a webpage tracking the status of the project. This changes
puts the pieces into the right place so that the webpage can be
created.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117436
Up until now, all references to `errno` were marked with `NOLINT`, since
it was technically calling an external function. This fixes the lint
rules so that `errno`, as well as `malloc`, `calloc`, `realloc`, and
`free` are all allowed to be called as external functions. All of the
relevant `NOLINT` comments have been removed, and the documentation has
been updated.
Reviewed By: sivachandra, lntue, aaron.ballman
Differential Revision: https://reviews.llvm.org/D113946
Also, the source layout document has been updated to reflect the current
layout of the `utils` directory.
Reviewers: PaulkaToast
Differential Revision: https://reviews.llvm.org/D74502
Summary:
Added fuzzing test for strcpy and some documentation related to fuzzing.
This will be the first step in integrating this with oss-fuzz.
Reviewers: sivachandra, abrachet
Reviewed By: sivachandra, abrachet
Subscribers: gchatelet, abrachet, mgorny, MaskRay, tschuett, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D74091
A toplevel target, `check-libc` has also been added.
Reviewers: abrachet, phosek
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D72177
Summary:
* The Python header generator has been removed.
* Docs giving a highlevel overview of the header gen scheme have been
added.
Reviewers: phosek, abrachet
Subscribers: mgorny, MaskRay, tschuett, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D70197
Setup demonstrated in this patch is only for ELF-ish platforms.
Also note:
1. Use of redirectors is a temporary scheme. They will be removed once
LLVM-libc has implementations for the redirected functions.
2. Redirectors are optional. One can choose to not include them in the
LLVM-libc build for their platform.
3. Even with redirectors used, we want to link to the system libc
dynamically.
Reviewers: dlj, hfinkel, jakehehrlich, phosek, stanshebs, theraven, alexshap
Subscribers: mgorny, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D69020
Summary:
This patch illustrates some of the features like modularity we want
in the new libc. Few other ideas like different kinds of testing, redirectors
etc are not yet present.
Reviewers: dlj, hfinkel, theraven, jfb, alexshap, jdoerfert
Subscribers: mgorny, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67867
llvm-svn: 373764