aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-08-09 15:11:11 +0200
committerNikita Popov <npopov@redhat.com>2024-08-09 15:12:11 +0200
commita15de177728ec83f37bdd8f39d4a8f57e95c3d21 (patch)
treef35f38b9ea53db4fdf6e28bf5f5d2435e06d8e3e
parent02645d66f93809f7f52b742987f350793136221f (diff)
downloadllvm-a15de177728ec83f37bdd8f39d4a8f57e95c3d21.zip
llvm-a15de177728ec83f37bdd8f39d4a8f57e95c3d21.tar.gz
llvm-a15de177728ec83f37bdd8f39d4a8f57e95c3d21.tar.bz2
Revert "Enable logf128 constant folding for hosts with 128bit floats (#96287)"
This reverts commit ccb2b011e577e861254f61df9c59494e9e122b38. Causes buildbot failures, e.g. on ppc64le builders.
-rw-r--r--llvm/CMakeLists.txt2
-rw-r--r--llvm/cmake/config-ix.cmake17
-rw-r--r--llvm/include/llvm/ADT/APFloat.h4
-rw-r--r--llvm/include/llvm/Support/float128.h14
-rw-r--r--llvm/lib/Analysis/CMakeLists.txt6
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp4
-rw-r--r--llvm/lib/Support/APFloat.cpp4
7 files changed, 33 insertions, 18 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 3cd6ff4..51f99cb 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -560,6 +560,8 @@ set(LLVM_USE_STATIC_ZSTD FALSE CACHE BOOL "Use static version of zstd. Can be TR
set(LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON")
+set(LLVM_HAS_LOGF128 "OFF" CACHE STRING "Use logf128 to constant fold fp128 logarithm calls. Can be ON, OFF, or FORCE_ON")
+
set(LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON")
set(LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 5e8c7c7..0aae13e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -247,6 +247,17 @@ else()
set(HAVE_LIBEDIT 0)
endif()
+if(LLVM_HAS_LOGF128)
+ include(CheckCXXSymbolExists)
+ check_cxx_symbol_exists(logf128 math.h HAS_LOGF128)
+
+ if(LLVM_HAS_LOGF128 STREQUAL FORCE_ON AND NOT HAS_LOGF128)
+ message(FATAL_ERROR "Failed to configure logf128")
+ endif()
+
+ set(LLVM_HAS_LOGF128 "${HAS_LOGF128}")
+endif()
+
# function checks
check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM)
find_package(Backtrace)
@@ -260,12 +271,6 @@ if(C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability-new")
endif()
-check_cxx_symbol_exists(logf128 cmath HAS_LOGF128)
-if(HAS_LOGF128)
- set(LLVM_HAS_LOGF128 On)
- add_compile_definitions(HAS_LOGF128)
-endif()
-
# Determine whether we can register EH tables.
check_symbol_exists(__register_frame "${CMAKE_CURRENT_LIST_DIR}/unwind.h" HAVE_REGISTER_FRAME)
check_symbol_exists(__deregister_frame "${CMAKE_CURRENT_LIST_DIR}/unwind.h" HAVE_DEREGISTER_FRAME)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 374fbcc..7039e96 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -378,7 +378,7 @@ public:
Expected<opStatus> convertFromString(StringRef, roundingMode);
APInt bitcastToAPInt() const;
double convertToDouble() const;
-#if defined(HAS_IEE754_FLOAT128)
+#ifdef HAS_IEE754_FLOAT128
float128 convertToQuad() const;
#endif
float convertToFloat() const;
@@ -1279,7 +1279,7 @@ public:
/// \pre The APFloat must be built using semantics, that can be represented by
/// the host float type without loss of precision. It can be IEEEquad and
/// shorter semantics, like IEEEdouble and others.
-#if defined(HAS_IEE754_FLOAT128)
+#ifdef HAS_IEE754_FLOAT128
float128 convertToQuad() const;
#endif
diff --git a/llvm/include/llvm/Support/float128.h b/llvm/include/llvm/Support/float128.h
index 618b320..e15a98d 100644
--- a/llvm/include/llvm/Support/float128.h
+++ b/llvm/include/llvm/Support/float128.h
@@ -9,16 +9,18 @@
#ifndef LLVM_FLOAT128
#define LLVM_FLOAT128
-#include <cmath>
-
namespace llvm {
-#ifdef HAS_LOGF128
-#if !defined(__LONG_DOUBLE_IBM128__) && (__SIZEOF_INT128__ == 16)
-typedef decltype(logf128(0.)) float128;
+#if defined(__clang__) && defined(__FLOAT128__) && \
+ defined(__SIZEOF_INT128__) && !defined(__LONG_DOUBLE_IBM128__)
+#define HAS_IEE754_FLOAT128
+typedef __float128 float128;
+#elif defined(__FLOAT128__) && defined(__SIZEOF_INT128__) && \
+ !defined(__LONG_DOUBLE_IBM128__) && \
+ (defined(__GNUC__) || defined(__GNUG__))
#define HAS_IEE754_FLOAT128
+typedef _Float128 float128;
#endif
-#endif // HAS_LOGF128
} // namespace llvm
#endif // LLVM_FLOAT128
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 63b4f71..2cb3547 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -161,3 +161,9 @@ add_llvm_component_library(LLVMAnalysis
Support
TargetParser
)
+
+include(CheckCXXSymbolExists)
+check_cxx_symbol_exists(logf128 math.h HAS_LOGF128)
+if(HAS_LOGF128)
+ target_compile_definitions(LLVMAnalysis PRIVATE HAS_LOGF128)
+endif()
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 87feb2e..084647b 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1781,7 +1781,7 @@ Constant *ConstantFoldFP(double (*NativeFP)(double), const APFloat &V,
return GetConstantFoldFPValue(Result, Ty);
}
-#if defined(HAS_IEE754_FLOAT128)
+#if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
Constant *ConstantFoldFP128(float128 (*NativeFP)(float128), const APFloat &V,
Type *Ty) {
llvm_fenv_clearexcept();
@@ -2114,7 +2114,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
if (IntrinsicID == Intrinsic::canonicalize)
return constantFoldCanonicalize(Ty, Call, U);
-#if defined(HAS_IEE754_FLOAT128)
+#if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
if (Ty->isFP128Ty()) {
if (IntrinsicID == Intrinsic::log) {
float128 Result = logf128(Op->getValueAPF().convertToQuad());
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 000fb4c..7f68c5a 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -3749,7 +3749,7 @@ double IEEEFloat::convertToDouble() const {
return api.bitsToDouble();
}
-#if defined(HAS_IEE754_FLOAT128)
+#ifdef HAS_IEE754_FLOAT128
float128 IEEEFloat::convertToQuad() const {
assert(semantics == (const llvm::fltSemantics *)&semIEEEquad &&
"Float semantics are not IEEEquads");
@@ -5406,7 +5406,7 @@ double APFloat::convertToDouble() const {
return Temp.getIEEE().convertToDouble();
}
-#if defined(HAS_IEE754_FLOAT128)
+#ifdef HAS_IEE754_FLOAT128
float128 APFloat::convertToQuad() const {
if (&getSemantics() == (const llvm::fltSemantics *)&semIEEEquad)
return getIEEE().convertToQuad();