Skip to content

Commit aaa3f72

Browse files
authored
[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: #64426
1 parent 2439bc4 commit aaa3f72

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,9 +3410,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
34103410
{ Src0->getType(), Src1->getType() });
34113411
return RValue::get(Builder.CreateCall(F, { Src0, Src1 }));
34123412
}
3413+
case Builtin::BI__builtin_frexpl: {
3414+
// Linux PPC will not be adding additional PPCDoubleDouble support.
3415+
// WIP to switch default to IEEE long double. Will emit libcall for
3416+
// frexpl instead of legalizing this type in the BE.
3417+
if (&getTarget().getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble())
3418+
break;
3419+
LLVM_FALLTHROUGH;
3420+
}
34133421
case Builtin::BI__builtin_frexp:
34143422
case Builtin::BI__builtin_frexpf:
3415-
case Builtin::BI__builtin_frexpl:
34163423
case Builtin::BI__builtin_frexpf128:
34173424
case Builtin::BI__builtin_frexpf16:
34183425
return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));

clang/test/CodeGen/math-builtins-long.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void foo(long double f, long double *l, int *i, const char *c) {
3535
__builtin_fabsl(f);
3636

3737
// F80: call { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80 %{{.+}})
38-
// PPC: call { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 %{{.+}})
38+
// PPC: call ppc_fp128 @frexpl(ppc_fp128 noundef %{{.+}}, ptr noundef %{{.+}})
3939
// X86F128: call { fp128, i32 } @llvm.frexp.f128.i32(fp128 %{{.+}})
4040
// PPCF128: call { fp128, i32 } @llvm.frexp.f128.i32(fp128 %{{.+}})
4141
__builtin_frexpl(f,i);

libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,9 @@ int main(int, char**) {
5858

5959
ASSERT_NOT_CONSTEXPR_CXX23(std::frexp(0.0f, &DummyInt) == 0.0f);
6060
ASSERT_NOT_CONSTEXPR_CXX23(std::frexp(0.0, &DummyInt) == 0.0);
61-
//FIXME: currently linux powerpc does not support this expansion
62-
// since 0.0L lowers to ppcf128 and special handling is required.
63-
#if !defined(__LONG_DOUBLE_IBM128__)
6461
ASSERT_NOT_CONSTEXPR_CXX23(std::frexp(0.0L, &DummyInt) == 0.0L);
65-
#endif
6662
ASSERT_NOT_CONSTEXPR_CXX23(std::frexpf(0.0f, &DummyInt) == 0.0f);
67-
#if !defined(__LONG_DOUBLE_IBM128__)
6863
ASSERT_NOT_CONSTEXPR_CXX23(std::frexpl(0.0L, &DummyInt) == 0.0L);
69-
#endif
7064

7165
ASSERT_NOT_CONSTEXPR_CXX23(std::ilogb(1.0f) == 0);
7266
ASSERT_NOT_CONSTEXPR_CXX23(std::ilogb(1.0) == 0);

0 commit comments

Comments
 (0)