[llvm] Enable logf128 constant folding for hosts with 128bit long double (PR #96287)
Matthew Devereau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 01:44:40 PDT 2024
================
@@ -271,6 +260,64 @@ if(C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability-new")
endif()
+function(logf128_test testname definition)
+ unset(LOGF128_TEST_RUN CACHE)
+ unset(LOGF128_TEST_COMPILE CACHE)
+ try_run(
+ LOGF128_TEST_RUN
----------------
MDevereau wrote:
x86 hosts with 80bit long doubles can compile logf128 but will return an error code. `__LDBL_MANT_DIG__` does work fine for hosts with 128bit long doubles, but this will also disable the fold for x86 targets with fp80 that can still perform an accurate fold with __float128 types. I'm struggling to think of an alternative way to select the most valid and best type at compile time to use without try_run based on the following criteria:
Logf128 symbol availability
Logf128 function prototype availability
Long double total size (Needs to be 16 bytes)
Long double mantissa size (Rules out fp80)
GCC version(12+ won't accept anything other than _Float128 for logf128)
If we're compiling with GCC or Clang (Clang needs to declare the logf128 prototype)
__float128 availability
_Float128 availability
https://github.com/llvm/llvm-project/pull/96287
More information about the llvm-commits
mailing list