summaryrefslogtreecommitdiff
path: root/libc/src/math/generic/expf.cpp
AgeCommit message (Collapse)Author
2025-06-12[libc][math] Refactor expf implementation to header-only in ↵lntue
src/__support/math folder. (#143790) This is a step in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-03-11[libc][math] Skip checking for exceptional values when ↵lntue
LIBC_MATH_SKIP_ACCURATE_PASS is set. (#130811)
2024-10-05[libc] remove errno.h includes (#110934)Job Henandez Lara
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-01-23[libc][NFC] Remove `FPBits` cast operator (#79142)Guillaume Chatelet
The semantics for casting can range from "bitcast" (same representation) to "different representation", to "type promotion". Here we remove the cast operator and force usage of `get_val` as the only function to get the floating point value, making the intent clearer and more consistent.
2024-01-23[reland][libc] Remove unnecessary `FPBits` functions and properties (#79128)Guillaume Chatelet
- reland #79113 - Fix aarch64 RISC-V build
2024-01-23Revert "[libc] Remove unnecessary `FPBits` functions and properties" (#79118)Guillaume Chatelet
Reverts llvm/llvm-project#79113 It broke aarch64 build bot machines.
2024-01-23[libc] Remove unnecessary `FPBits` functions and properties (#79113)Guillaume Chatelet
This patch reduces the surface of `FPBits`.
2024-01-18[libc][NFC] Introduce a Sign type for FPBits (#78500)Guillaume Chatelet
Another patch is needed to cover `DyadicFloat` and `NormalFloat` constructors.
2023-12-19[libc][NFC] Use FPBits builders instead of custom constructs (#75942)Guillaume Chatelet
2023-12-11[libc][NFC] Fix mixed up biased/unbiased exponent (#75037)Guillaume Chatelet
According to [wikipedia](https://en.wikipedia.org/wiki/Exponent_bias) the "biased exponent" is the encoded form that is always positive whereas the unbiased form is the actual "real" exponent that can be positive or negative. `FPBits` seems to be using `unbiased_exponent` to describe the encoded form (unsigned). This patch simply use `biased` instead of `unbiased`.
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-06-12[libc] Add platform independent floating point rounding mode checks.Tue Ly
Many math functions need to check for floating point rounding modes to return correct values. Currently most of them use the internal implementation of `fegetround`, which is platform-dependent and blocking math functions to be enabled on platforms with unimplemented `fegetround`. In this change, we add platform independent rounding mode checks and switching math functions to use them instead. https://github.com/llvm/llvm-project/issues/63016 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D152280
2023-02-24[libc][math] Set floating point exceptions for exp*f, sinhf, and coshf.Tue Ly
Set FE_OVERFLOW and FE_UNDERFLOW for expf, exp2f, exp10f, expm1f, sinhf and coshf. Reviewed By: sivachandra, renyichen Differential Revision: https://reviews.llvm.org/D144340
2023-02-10[libc] Move likely/unlikely to the optimization headerGuillaume Chatelet
2023-02-07[libc][NFC] Move attributes from common to macros folderGuillaume Chatelet
2022-07-26[libc] Use nearest_integer instructions to improve expf performance.Tue Ly
Use nearest_integer instructions to improve expf performance. Performance tests with CORE-MATH's perf tool: Before the patch: ``` $ ./perf.sh expf LIBC-location: /home/lnt/experiment/llvm-project/build/projects/libc/lib/libllvmlibc.a GNU libc version: 2.31 GNU libc release: stable CORE-MATH reciprocal throughput : 9.860 System LIBC reciprocal throughput : 7.728 LIBC reciprocal throughput : 12.363 $ ./perf.sh expf --latency LIBC-location: /home/lnt/experiment/llvm-project/build/projects/libc/lib/libllvmlibc.a GNU libc version: 2.31 GNU libc release: stable CORE-MATH latency : 42.802 System LIBC latency : 35.941 LIBC latency : 49.808 ``` After the patch: ``` $ ./perf.sh expf LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a GNU libc version: 2.31 GNU libc release: stable CORE-MATH reciprocal throughput : 9.441 System LIBC reciprocal throughput : 7.382 LIBC reciprocal throughput : 8.843 $ ./perf.sh expf --latency LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a GNU libc version: 2.31 GNU libc release: stable CORE-MATH latency : 44.192 System LIBC latency : 37.693 LIBC latency : 44.145 ``` Reviewed By: zimmermann6 Differential Revision: https://reviews.llvm.org/D130498
2022-06-03[libc] Automatically add -mfma flag for architectures supporting FMA.Tue Ly
Detect if the architecture supports FMA instructions and if the targets depend on fma. Reviewed By: gchatelet Differential Revision: https://reviews.llvm.org/D123615
2022-03-25[libc] Improve the performance of expf.Tue Ly
Reduce the polynomial's degree from 7 down to 4. Currently we use a degree-7 minimax polynomial on an interval of length 2^-7 around 0 to compute `expf`. Based on the suggestion of @santoshn and the RLIBM project (https://github.com/rutgers-apl/rlibm-all/blob/main/source/float/exp.c) and the improvement we made with `exp2f` in https://reviews.llvm.org/D122346, it is possible to have a good polynomial of degree-4 on a subinterval of length 2^(-7) to approximate e^x. We did try to either reduce the degree of the polynomial down to 3 or increase the interval size to 2^(-6), but in both cases the number of exceptional values exploded. So we settle with using a degree-4 polynomial of the interval of size 2^(-7) around 0. Reviewed By: sivachandra, zimmermann6, santoshn Differential Revision: https://reviews.llvm.org/D122418
2022-03-15[libc] Implement expm1f function that is correctly rounded for all rounding ↵Tue Ly
modes. Implement expm1f function that is correctly rounded for all rounding modes. This is based on expf implementation. From exhaustive testings, using expf implementation, and subtract 1.0 before rounding the final result to single precision gives correctly rounded results for all |x| > 2^-4 with 1 exception. When |x| < 2^-25, we use x + x^2 (implemented with a single fma). And for 2^-25 <= |x| <= 2^-4, we use a single degree-8 minimax polynomial generated by Sollya. Reviewed By: sivachandra, zimmermann6 Differential Revision: https://reviews.llvm.org/D121574
2022-03-11[libc] Implement expf function that is correctly rounded for all rounding modes.Tue Ly
Implement expf function that is correctly rounded for all rounding modes. Reviewed By: sivachandra, zimmermann6 Differential Revision: https://reviews.llvm.org/D121440
2021-02-03[libc][NFC] Move generic math implementations to the generic directory.Siva Chandra
This expands the pattern suggest in https://reviews.llvm.org/D95850 to all math functions.