Skip to content

[flang] add folding support for quad bessels #77314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

jeanPerier
Copy link
Contributor

This is done using libquadmath and the mappings are only available if libquadmath was found by cmake.
Support for non quad bessels is already available on POSIX platform using libm extensions.

This is done using libquadmath and the mappings are only available
if libquadmath was found by cmake.

Support for non quad bessels is already available on POSIX platform
using libm extensions.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jan 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2024

@llvm/pr-subscribers-flang-semantics

Author: None (jeanPerier)

Changes

This is done using libquadmath and the mappings are only available if libquadmath was found by cmake.
Support for non quad bessels is already available on POSIX platform using libm extensions.


Full diff: https://github.com/llvm/llvm-project/pull/77314.diff

1 Files Affected:

  • (modified) flang/lib/Evaluate/intrinsics-library.cpp (+7)
diff --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index 892b8d0b6a0639..e68c5ed3f6a8b1 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -321,6 +321,7 @@ template <> struct HostRuntimeLibrary<float, LibraryVersion::LibmExtensions> {
 template <> struct HostRuntimeLibrary<__float128, LibraryVersion::Libm> {
   using F = FuncPointer<__float128, __float128>;
   using F2 = FuncPointer<__float128, __float128, __float128>;
+  using FN = FuncPointer<__float128, int, __float128>;
   static constexpr HostRuntimeFunction table[]{
       FolderFactory<F, F{::acosq}>::Create("acos"),
       FolderFactory<F, F{::acoshq}>::Create("acosh"),
@@ -329,6 +330,12 @@ template <> struct HostRuntimeLibrary<__float128, LibraryVersion::Libm> {
       FolderFactory<F, F{::atanq}>::Create("atan"),
       FolderFactory<F2, F2{::atan2q}>::Create("atan2"),
       FolderFactory<F, F{::atanhq}>::Create("atanh"),
+      FolderFactory<F, F{::j0q}>::Create("bessel_j0"),
+      FolderFactory<F, F{::j1q}>::Create("bessel_j1"),
+      FolderFactory<FN, FN{::jnq}>::Create("bessel_jn"),
+      FolderFactory<F, F{::y0q}>::Create("bessel_y0"),
+      FolderFactory<F, F{::y1q}>::Create("bessel_y1"),
+      FolderFactory<FN, FN{::ynq}>::Create("bessel_yn"),
       FolderFactory<F, F{::cosq}>::Create("cos"),
       FolderFactory<F, F{::coshq}>::Create("cosh"),
       FolderFactory<F, F{::erfq}>::Create("erf"),

Copy link
Contributor

@psteinfeld psteinfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a test.

Otherwise, all builds and tests correctly and looks good.

@jeanPerier
Copy link
Contributor Author

It would be nice to have a test.

Is there a place where quadmath folding is already tested ? I briefly looked and could not find/did not want to add some ifdef HAS_QUADMATHLIB dependent testing.

@jeanPerier jeanPerier merged commit 4cb1d91 into llvm:main Jan 9, 2024
@jeanPerier jeanPerier deleted the jpr-bessel-folding branch January 9, 2024 08:28
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
This is done using libquadmath and the mappings are only available if
libquadmath was found by cmake.
Support for non quad bessels is already available on POSIX platform
using libm extensions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants