[flang-commits] [flang] [flang] Use libm routine for compile-time folding on AIX (PR #114106)
Kelvin Li via flang-commits
flang-commits at lists.llvm.org
Wed Nov 6 15:01:05 PST 2024
================
@@ -277,6 +277,32 @@ static std::complex<HostT> StdPowF2B(
return std::pow(x, y);
}
+#ifdef _AIX
+extern "C" {
+void csqrtf_wrapper(const float[], float[]);
+void csqrt_wrapper(const double[], double[]);
+} // extern "C"
+#endif
+
+template <typename HostT>
+static std::complex<HostT> CSqrt(const std::complex<HostT> &x) {
+ std::complex<HostT> res;
+#if _AIX
+ HostT y[2]{x.real(), x.imag()};
+ HostT r[2];
+ if constexpr (std::is_same_v<HostT, float>) {
+ csqrtf_wrapper(y, r);
+ } else if constexpr (std::is_same_v<HostT, double>) {
+ csqrt_wrapper(y, r);
+ }
----------------
kkwli wrote:
Good idea. I will add it.
https://github.com/llvm/llvm-project/pull/114106
More information about the flang-commits
mailing list