aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Huang <lei@ca.ibm.com>2023-12-15 17:23:16 -0500
committerGitHub <noreply@github.com>2023-12-15 17:23:16 -0500
commitaaa3f72c1ce6e1757df79c0d02e0675201ee07a3 (patch)
tree6067fe030a414fcf31dfd556f9a4fce39914cb12
parent2439bc4a801df88b17764de50664e6b3a8e3c507 (diff)
downloadllvm-aaa3f72c1ce6e1757df79c0d02e0675201ee07a3.zip
llvm-aaa3f72c1ce6e1757df79c0d02e0675201ee07a3.tar.gz
llvm-aaa3f72c1ce6e1757df79c0d02e0675201ee07a3.tar.bz2
[PowerPC] Emit libcall to frexpl for calls to frexp(ppcDoublDouble) (#75226)
On Linux PPC call lib func ``frexpl`` for calls to ``frexp()`` for input of type PPCDoubleDouble. Fixes bug: https://github.com/llvm/llvm-project/issues/64426
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp9
-rw-r--r--clang/test/CodeGen/math-builtins-long.c2
-rw-r--r--libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp6
3 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 353b7930..3327866 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3410,9 +3410,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
{ Src0->getType(), Src1->getType() });
return RValue::get(Builder.CreateCall(F, { Src0, Src1 }));
}
+ case Builtin::BI__builtin_frexpl: {
+ // Linux PPC will not be adding additional PPCDoubleDouble support.
+ // WIP to switch default to IEEE long double. Will emit libcall for
+ // frexpl instead of legalizing this type in the BE.
+ if (&getTarget().getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble())
+ break;
+ LLVM_FALLTHROUGH;
+ }
case Builtin::BI__builtin_frexp:
case Builtin::BI__builtin_frexpf:
- case Builtin::BI__builtin_frexpl:
case Builtin::BI__builtin_frexpf128:
case Builtin::BI__builtin_frexpf16:
return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));
diff --git a/clang/test/CodeGen/math-builtins-long.c b/clang/test/CodeGen/math-builtins-long.c
index f3c328d..ad0d212 100644
--- a/clang/test/CodeGen/math-builtins-long.c
+++ b/clang/test/CodeGen/math-builtins-long.c
@@ -35,7 +35,7 @@ void foo(long double f, long double *l, int *i, const char *c) {
__builtin_fabsl(f);
// F80: call { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80 %{{.+}})
- // PPC: call { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 %{{.+}})
+ // PPC: call ppc_fp128 @frexpl(ppc_fp128 noundef %{{.+}}, ptr noundef %{{.+}})
// X86F128: call { fp128, i32 } @llvm.frexp.f128.i32(fp128 %{{.+}})
// PPCF128: call { fp128, i32 } @llvm.frexp.f128.i32(fp128 %{{.+}})
__builtin_frexpl(f,i);
diff --git a/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp b/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp
index 3151106..a07260a 100644
--- a/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp
+++ b/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp
@@ -58,15 +58,9 @@ int main(int, char**) {
ASSERT_NOT_CONSTEXPR_CXX23(std::frexp(0.0f, &DummyInt) == 0.0f);
ASSERT_NOT_CONSTEXPR_CXX23(std::frexp(0.0, &DummyInt) == 0.0);
-//FIXME: currently linux powerpc does not support this expansion
-// since 0.0L lowers to ppcf128 and special handling is required.
-#if !defined(__LONG_DOUBLE_IBM128__)
ASSERT_NOT_CONSTEXPR_CXX23(std::frexp(0.0L, &DummyInt) == 0.0L);
-#endif
ASSERT_NOT_CONSTEXPR_CXX23(std::frexpf(0.0f, &DummyInt) == 0.0f);
-#if !defined(__LONG_DOUBLE_IBM128__)
ASSERT_NOT_CONSTEXPR_CXX23(std::frexpl(0.0L, &DummyInt) == 0.0L);
-#endif
ASSERT_NOT_CONSTEXPR_CXX23(std::ilogb(1.0f) == 0);
ASSERT_NOT_CONSTEXPR_CXX23(std::ilogb(1.0) == 0);