Skip to content

Commit 4cc6905

Browse files
committed
Enable logf128 constant folding for AArch64
AArch64 has a long double bit length of 128. Therefore, it can benefit from constant fp128 folding. GCC versions more recent than version 12 must use the _Float128 type for logf128.
1 parent 0f1b627 commit 4cc6905

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

llvm/include/llvm/Support/float128.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111

1212
namespace llvm {
1313

14-
#if defined(__clang__) && defined(__FLOAT128__) && \
14+
#if defined(__aarch64__)
15+
#define HAS_IEE754_FLOAT128
16+
#if (defined(__GNUC__) && __GNUC__ > 12)
17+
typedef _Float128 float128;
18+
#else
19+
typedef long double float128;
20+
#endif
21+
#elif defined(__clang__) && defined(__FLOAT128__) && \
1522
defined(__SIZEOF_INT128__) && !defined(__LONG_DOUBLE_IBM128__)
1623
#define HAS_IEE754_FLOAT128
1724
typedef __float128 float128;

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,8 +1784,8 @@ Constant *ConstantFoldFP(double (*NativeFP)(double), const APFloat &V,
17841784
}
17851785

17861786
#if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
1787-
Constant *ConstantFoldFP128(long double (*NativeFP)(long double),
1788-
const APFloat &V, Type *Ty) {
1787+
Constant *ConstantFoldFP128(float128 (*NativeFP)(float128), const APFloat &V,
1788+
Type *Ty) {
17891789
llvm_fenv_clearexcept();
17901790
float128 Result = NativeFP(V.convertToQuad());
17911791
if (llvm_fenv_testexcept()) {

0 commit comments

Comments
 (0)