[flang-commits] [flang] 666df54 - [flang] Fold double bessel functions on Windows. (#130253)

via flang-commits flang-commits at lists.llvm.org
Wed Apr 2 06:43:12 PDT 2025


Author: مهدي شينون (Mehdi Chinoune)
Date: 2025-04-02T14:43:09+01:00
New Revision: 666df54ea6c3d9cb735fc2fcaf1a4802e675f8d0

URL: https://github.com/llvm/llvm-project/commit/666df54ea6c3d9cb735fc2fcaf1a4802e675f8d0
DIFF: https://github.com/llvm/llvm-project/commit/666df54ea6c3d9cb735fc2fcaf1a4802e675f8d0.diff

LOG: [flang] Fold double bessel functions on Windows. (#130253)

There are no functions for `float`.
see:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/bessel-functions-j0-j1-jn-y0-y1-yn

Added: 
    

Modified: 
    flang/lib/Evaluate/intrinsics-library.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/intrinsics-library.cpp b/flang/lib/Evaluate/intrinsics-library.cpp
index 6363acfc5eb40..9820aa3d2ea3d 100644
--- a/flang/lib/Evaluate/intrinsics-library.cpp
+++ b/flang/lib/Evaluate/intrinsics-library.cpp
@@ -559,6 +559,23 @@ struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
 #endif // HAS_FLOAT80 || HAS_LDBL128
 #endif //_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
 
+#ifdef _WIN32
+template <> struct HostRuntimeLibrary<double, LibraryVersion::LibmExtensions> {
+  using F = FuncPointer<double, double>;
+  using FN = FuncPointer<double, int, double>;
+  static constexpr HostRuntimeFunction table[]{
+      FolderFactory<F, F{::_j0}>::Create("bessel_j0"),
+      FolderFactory<F, F{::_j1}>::Create("bessel_j1"),
+      FolderFactory<FN, FN{::_jn}>::Create("bessel_jn"),
+      FolderFactory<F, F{::_y0}>::Create("bessel_y0"),
+      FolderFactory<F, F{::_y1}>::Create("bessel_y1"),
+      FolderFactory<FN, FN{::_yn}>::Create("bessel_yn"),
+  };
+  static constexpr HostRuntimeMap map{table};
+  static_assert(map.Verify(), "map must be sorted");
+};
+#endif
+
 /// Define pgmath description
 #if LINK_WITH_LIBPGMATH
 // Only use libpgmath for folding if it is available.


        


More information about the flang-commits mailing list