llvm/libc/cmake/modules
Tue Ly d883a4ad02 [libc] Implement sinf function that is correctly rounded to all rounding modes.
Implement sinf function that is correctly rounded to all rounding modes.

- We use a simple range reduction for `pi/16 < |x|` :
    Let `k = round(x / pi)` and `y = (x/pi) - k`.
    So `k` is an integer and `-0.5 <= y <= 0.5`.
Then
```
sin(x) = sin(y*pi + k*pi)
          = (-1)^(k & 1) * sin(y*pi)
          ~ (-1)^(k & 1) * y * P(y^2)
```
    where `y*P(y^2)` is a degree-15 minimax polynomial generated by Sollya with:
```
> P = fpminimax(sin(x*pi)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|D...|], [0, 0.5]);
```

- Performance benchmark using perf tool from CORE-MATH project
(https://gitlab.inria.fr/core-math/core-math/-/tree/master) on Ryzen 1700:
Before this patch (not correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput   : 17.892
System LIBC reciprocal throughput : 25.559
LIBC reciprocal throughput        : 29.381
```
After this patch (correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput   : 17.896
System LIBC reciprocal throughput : 25.740

LIBC reciprocal throughput        : 27.872
LIBC reciprocal throughput        : 20.012     (with `-msse4.2` flag)
LIBC reciprocal throughput        : 14.244     (with `-mfma` flag)
```

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D123154
2022-07-22 10:07:31 -04:00
..
cpu_features
LLVMLibCArchitectures.cmake
LLVMLibCCheckCpuFeatures.cmake [libc] Automatically add -mfma flag for architectures supporting FMA. 2022-06-03 01:21:20 -04:00
LLVMLibCCheckMPFR.cmake
LLVMLibCFlagRules.cmake [libc] Add float type and flag for nearest_integer to enable SSE4.2. 2022-07-22 09:29:41 -04:00
LLVMLibCHeaderRules.cmake
LLVMLibCLibraryRules.cmake [libc][Obvious] Do not add __NO_ to targets with FLAG__NO suffix. 2022-06-30 10:45:59 -04:00
LLVMLibCObjectRules.cmake [libc] Implement sinf function that is correctly rounded to all rounding modes. 2022-07-22 10:07:31 -04:00
LLVMLibCRules.cmake
LLVMLibCTargetNameUtils.cmake
LLVMLibCTestRules.cmake [libc][NFC] Make all integration tests depend on the threads implementation. 2022-07-13 20:51:12 +00:00