[flang-commits] [flang] [flang] Use libm routine for compile-time folding on AIX (PR #114106)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Nov 6 14:39:02 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);
+ }
----------------
klausler wrote:
`} else { DIE("bad complex component type"); }` would seem like a good idea here.
https://github.com/llvm/llvm-project/pull/114106
More information about the flang-commits
mailing list