Commit Graph
169 Commits
Author SHA1 Message Date
hulxvandMuhammad Bassiouni bbd4d67f0b [libc][math] Refactor fdiv family to header-only (#182192)
Refactors the fdiv math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182191

Target Functions:
  - fdiv
  - fdivf128
  - fdivl

---------

Co-authored-by: Muhammad Bassiouni <60100307+bassiounix@users.noreply.github.com>
2026-04-26 00:57:03 +03:00
hulxvandbassiounix 55af9c2615 [libc][math] Refactor dsub family to header-only (#182160)
Refactors the dsub math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182159

Target Functions:
  - dsubf128
  - dsubl

---------

Co-authored-by: bassiounix <muhammad.m.bassiouni@gmail.com>
2026-04-25 10:09:30 +03:00
hulxv 125f69d71a [libc][math] Refactor fabs family to header-only (#182173)
Refactors the fabs math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182172

Target Functions:
  - fabs
  - fabsbf16
  - fabsf
  - fabsf128
  - fabsf16
  - fabsl
2026-04-24 22:47:39 +03:00
hulxv a1a4da0416 [libc][math] Refactor ddiv family to header-only (#182149)
Refactors the ddiv math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182148

Target Functions:
  - ddivf128
  - ddivl
2026-04-24 20:49:28 +03:00
hulxv b093148328 [libc][math] Refactor dmul family to header-only (#182151)
Refactors the dmul math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182150

Target Functions:
  - dmulf128
  - dmull
2026-04-24 17:49:19 +03:00
Zorojuroandbassiounix b7f54fd7ec [libc][math] Refactor logbbf16 to header-only (#189194)
Co-authored-by: bassiounix <muhammad.m.bassiouni@gmail.com>
2026-04-18 21:41:15 +02:00
hulxvandbassiounix 23361e18ac [libc][math] Refactor copysign family to header-only (#182137)
Refactors the copysign math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182136

Target Functions:
  - copysign
  - copysignbf16
  - copysignf
  - copysignf128
  - copysignf16
  - copysignl

---------

Co-authored-by: bassiounix <muhammad.m.bassiouni@gmail.com>
2026-04-13 18:03:52 +02:00
Zorojuro bdc11929aa [libc][math] Fix: add log10p1f16 to shared math (#189185)
This PR intends to add the log10p1f16 function to shared math, along
with adding tests for it and Bazel which was missed in
[a7d1a87](https://github.com/llvm/llvm-project/commit/a7d1a87b30ce626678d33fe1c12e647f7ce4fb20).
2026-04-13 11:00:03 +02:00
Zorojuro ec944346dd [libc][math] Fix: add log2p1f16 to shared math (#189179)
This PR intends to add the log2p1f16 function to shared math, along with
adding tests for it and bazel which was missed in
[f0ce26d](https://github.com/llvm/llvm-project/commit/f0ce26d06d822fd6985d227dc1be9d218977e334).
2026-04-13 10:57:16 +02:00
Zorojuroandbassiounix f1c2e3cc68 [libc][math] Refactor cbrtbf16 function header-only (#188204)
Co-authored-by: bassiounix <muhammad.m.bassiouni@gmail.com>
2026-04-09 00:40:22 +02:00
lntue d52daeac79 [libc] Fix the remaining long double issue in shared_math_test.cpp. (#190098) 2026-04-01 22:47:29 -04:00
Zorojuroandbassiounix 15a7c45163 [libc][math][c23] Add asinbf16 math function (#184170)
Co-authored-by: bassiounix <muhammad.m.bassiouni@gmail.com>
2026-03-30 21:29:55 +02:00
lntue 6ae395a875 [libc][NFC] Guard long double type in shared_math_tests. (#189373)
Skip long double tests when long double is double-double.
Also adjust constant literals.
2026-03-30 10:05:16 -04:00
Mohamed Emad 1bb03026b6 [libc][math][c23] implement double-precision asinpi (#188158)
Implement the double precision version of the asinpi c23 math function
2026-03-29 10:18:07 -04:00
Anonmiraj e06b5e53a2 [libc][math] Implement C23 half precision erfc function (#180930)
Add support for the half-precision complementary error function
`erfcf16``, using a Sollya generated polynomial implementation with
proper handling of special cases.

Extend the MPFR utilities with erfc support to allow tests.

closes: #180927
2026-03-27 10:42:03 -04:00
Muhammad Bassiouni b4f50cfd4a [libc][math] Qualify ceil functions to constexpr (#184948) 2026-03-24 00:25:42 +02:00
Zorojuro aa62224a73 [libc][math] Refactor sqrtbf16 function header-only (#187849) 2026-03-22 00:51:40 +02:00
Muhammad Bassiouni eea589f951 [libc][math] Qualify log with constant evaluation support (#184745)
Lay the ground for C++26 `constexpr` math functions:
- Introduce `LIBC_ENABLE_CONSTEXPR` macro switch to specify the desire
of `constexpr`-only code route.
- Introduce `LIBC_HAS_CONSTANT_EVALUATION` to indicate that we are using
`constexpr`-only code in all dependent functions.
- Introduce `LIBC_CONSTEXPR` macro qualifier to aid in altering the
signature of non-`constexpr` functions.

Note that non-`constexpr` qualified functions are caused by the
exploitation of non-`constexpr` compatible utils, resulting in
non-qualified dependent function, but it can be modified to be qualified
using other code routes.

If the function is `constexpr` compatible, then it's prohibited to use
`LIBC_CONSTEXPR` as a function qualifier. We only qualify it with
`constexpr` as usual.

`LIBC_CONSTEXPR` may or may not evaluate to `constexpr` depending on the
environment configurations, thus it's only used to modify the function
signature in constant evaluation context and remove the qualifier if
it's not desired (depending on provided configurations).

Possible side effects:
- Current qualified routes may or may not produce the desired ULP, this
is implementation dependent (function by function basis) and needs
further testing of the chosen code route.
- The shared tests in the current configuration can still compile with
unsupported compiler. I didn't want to raise compilation error with
unsupported compilers now, but we need to push compiler support with
newer versions for this one to work as intended.
2026-03-21 23:55:05 +02:00
Zorojuro 7d7cd745af [libc][math][c23] Add atanbf16 function (#184019)
This PR intends to add atanbf16 higher math function for BFloat16 type
along with the tests.
2026-03-21 11:09:11 -04:00
Mohamed Emad 4db2ce4d54 [libc][math] Refactor dadd family to header-only (#182142)
Closes https://github.com/llvm/llvm-project/issues/182141
2026-03-19 06:37:35 +02:00
Manthan Singla 42b75ed85f [libc][math] Refactor bf16divf128 to Header Only (#186641)
closes #181024
2026-03-19 01:47:22 +02:00
Muhammad Bassiouni bed5e7dc20 [libc][math] Refactor fmaf16 implementation to header-only in src/__support/math folder. (#163977) 2026-03-17 21:35:08 +02:00
Muhammad Bassiouni e6f0ec8343 [libc][math] Refactor fmaf implementation to header-only in src/__support/math folder. (#163970)
Part of #147386

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
2026-03-17 21:33:06 +02:00
Muhammad Bassiouni d0d1f0b7af [libc][math] Refactor fma implementation to header-only in src/__support/math folder. (#163968)
Part of #147386

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
2026-03-17 21:24:27 +02:00
Zorojuro 0a3384b969 [libc][math] Refactor log_bf16 to Header (#186618) 2026-03-16 17:13:19 +00:00
Anirudh Mathur 6e224cede2 [libc][math] Refactor bf16fma to Header Only (#182572)
Fixes #181625
2026-03-16 17:05:54 +00:00
Abhijeet cf979d5a96 [libc][math] Refactored atanpif16 to header only (#184316)
Fixes #178105
2026-03-16 18:57:29 +02:00
Xinlong Chen 458096d5f8 [libc][math][c23] Add atan2f16 function (#183531)
Add atan2f16 function

closes https://github.com/llvm/llvm-project/issues/180969
Part of https://github.com/llvm/llvm-project/issues/95250.

also refactor to header only, it's a part of
https://github.com/llvm/llvm-project/issues/147386
2026-03-13 22:12:44 +02:00
sid bc108761e9 [libc][math] Refactor bf16div to be header-only (#181400)
Closes #181022
Part of #147386
2026-03-13 20:08:00 +00:00
Chinmay Ingle 4fdf089073 [libc][math] Move hypot to shared/math and make it constexpr (#177588)
Closes #175339
2026-03-13 19:57:05 +00:00
Anonmiraj 785581213c [libc][math] Implement C23 half precision erf function (#179251)
The implementation reuses the approach in `erff`


Closes #133112
2026-03-13 10:16:59 -04:00
Zorojuro ad054822eb [libc][math][c23] Add hypotbf16 function (#183460)
This PR intends to add hypotbf16 higher math function for BFloat16 type
along with the tests.
2026-03-13 10:11:33 -04:00
Zorojuro 0bebee6782 [libc][math][c++23] Add Fmabf16 math function (#182836)
closes #180171 
part of #177259 

Here are some extra changes apart from the usual which were needed
1. `libc/src/__support/FPUtil/generic/add_sub.h` → +0 -0 error
2. `libc/src/__support/FPUtil/generic/FMA.h` → implemented to handle
fmabf16(Normal,Normal,+/-INF)

```jsx
/home/runner/work/llvm-project/llvm-project/libc/test/src/math/fmabf16_test.cpp:62: FAILURE
Failed to match __llvm_libc_23_0_0_git::fmabf16(x, y, z) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<mpfr::Operation::Fma>( input, __llvm_libc_23_0_0_git::fmabf16(x, y, z), 0.5, mpfr::RoundingMode::Nearest).
Input decimal: x: 338953138925153547590470800371487866880.00000000000000000000000000000000000000000000000000 y: 338953138925153547590470800371487866880.00000000000000000000000000000000000000000000000000 z: -inf
 First input bits: 0x7F7F = (S: 0, E: 0x00FE, M: 0x007F)
Second input bits: 0x7F7F = (S: 0, E: 0x00FE, M: 0x007F)
 Third input bits: (-Infinity)
Libc result: nan
MPFR result: -inf
Libc floating point result bits: (NaN)
              MPFR rounded bits: (-Infinity)
```

1. ~~`libc/src/__support/FPUtil/bfloat16.h` → to handle *= operator for
Bfloat16 ( uses the already available mult operator)~~
moved to  #182882 

The exhaustive test currently includes subnormal range and for checking
for specific edge cases . This is due to the repeated failure at <2^32
input space specifically only for ubuntu 24.04 and 24.04-arm
The removed tests included -> PositiveRange and NegativeRange for
Normals and an extra positive test for subnormals/Denormals

Let me know if there are any changes expected or anything I missed in
this .
 cc: @lntue @krishna2803 @overmighty
2026-03-13 05:33:52 +00:00
Zorojuro 9548db811e [libc][math] Refactor ffmaf128 into a header only. (#184751)
closes #175325 
part of #147386
2026-03-05 23:31:40 +02:00
Mohamed Emad 62cfe1659e [libc][math][c23] implement C23 acospif math function (#183661)
Implementing C23 `acospi` math function for single-precision with the
header-only approach that is followed since #147386
2026-02-28 04:32:45 +02:00
Mohamed Emad fb6b470cae [libc][math] Refactor floor family to header-only (#182194)
Refactors the floor math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182193

Target Functions:
  - floor
  - floorbf16
  - floorf
  - floorf128
  - floorf16
  - floorl
2026-02-28 04:32:22 +02:00
Mohamed Emad ca04a70891 [libc][math] Refactor bf16sub family to header-only (#182115)
Refactors the bf16sub math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182114

Target Functions:
  - bf16sub
  - bf16subf
  - bf16subf128
2026-02-27 21:38:30 +02:00
Anonmiraj 7e39b280e8 [libc][math] Refactor nextafter family to header-only (#181673)
closes #181672
2026-02-27 01:52:57 +02:00
Zorojuro 27905b1196 [libc][math] Refactor f16sqrtf128 to Header Only. (#183542)
closes  #175328
part of https://github.com/llvm/llvm-project/issues/147386
2026-02-26 20:48:56 +02:00
Weiwen He 3839878d20 [libc][math] Refactor tanpif16 to header-only (#181240)
Part of #147386

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

Closes #181207
2026-02-26 17:49:50 +00:00
Mohamed Emad 8f3dd82a0a [libc][math][c23] implement asinpif function (#181511)
Implementing `asinpi` for single-precision. it continues what is done in
#152690 that implemented `asinpif16` with header-only approach that is
followed since #147386
2026-02-26 05:05:49 +02:00
Mohamed Emad d7cdfa1096 [libc][math] Refactor fdim family to header-only (#182190)
Refactors the fdim math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182188

Target Functions:
  - fdim
  - fdimbf16
  - fdimf
  - fdimf128
  - fdimf16
  - fdiml
2026-02-25 21:06:01 +00:00
Anonmiraj bfaa15ee56 [libc][math] Refactor float16 basic operations to header-only (#181745)
closes: #181744
2026-02-25 20:56:33 +02:00
Anonmiraj d2d862a544 [libc][math] Refactor nexttoward family to header-only (#181685)
Closes https://github.com/llvm/llvm-project/issues/181684
2026-02-25 18:20:18 +00:00
Anonmiraj af1bdad42c [libc][math] Refactor nextup family to header-only (#181688)
Closes https://github.com/llvm/llvm-project/issues/181687
2026-02-25 17:58:11 +00:00
Anonmiraj 4ef6a8a16e [libc][math] Refactor nextdown family to header-only (#181679)
closes #181678
2026-02-24 21:38:33 +02:00
Anonmiraj 4a1f565c85 [libc][math] Refactor setpayloadsig family to header-only (#183113)
closes : #181823
2026-02-24 20:47:20 +02:00
Julian Pokrovsky 8ed290cd1d [libc][math] Refactor asinpif16 to Header Only (#179021)
Resolves https://github.com/llvm/llvm-project/issues/178103

Part of #147386

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
2026-02-24 19:55:16 +02:00
Anonmiraj 03388af319 [libc][math] Refactor setpayload family to header-only (#182922)
part of #181823
2026-02-24 19:50:07 +02:00
Mohamed Emad 05a039489d [libc][math] Refactor bf16mul family to header-only (#182018)
Refactors the bf16mul math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182017

Target Functions:
  - bf16mul
  - bf16mulf
  - bf16mulf128
  - bf16mull
2026-02-24 02:24:01 +00:00