[llvm] Enable logf128 constant folding for hosts with 128bit long double (PR #96287)

Matthew Devereau via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 06:03:58 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:

Firstly, thanks for your patience with this review. 

I'm still unsure how to differentiate in a header file between `_Float128` and `long double` for GCC12+, where trying to pass in anything other than GCC 12+'s dedicated _Float128 type will cause a compilation error. A condition along the lines of
```c++
#if (__LDBL_MANT_DIG__ == 113) && !defined(__LONG_DOUBLE_IBM128__) && (__SIZEOF_INT128__ == 16)
typedef long double float128;
#else
```
will be valid for GCC12 and GCC11 while it is actually only valid for GCC11: long double isn't valid for logf128 anymore after GCC12, but the host still has a long double mantissa size of 113.

https://github.com/llvm/llvm-project/pull/96287


More information about the llvm-commits mailing list