[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 Aug 6 07:58:02 PDT 2024


================
@@ -9,18 +9,17 @@
 #ifndef LLVM_FLOAT128
 #define LLVM_FLOAT128
 
+#include <cmath>
+
 namespace llvm {
 
-#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__))
+#ifdef HAS_LOGF128
+#if (__LDBL_MANT_DIG__ == 113) && !defined(__LONG_DOUBLE_IBM128__) &&          \
----------------
MDevereau wrote:

Sorry for the late update, I've been away for a few weeks. I believe its unnecessary in this version, if `HAS_LOGF128` is true the logf128 function prototype should return a valid IEEE 128-bit float.

I believe this will expose a problem I've seen where x86 targets with fp80 will return a slightly different result from AArch64. I.e., AArch64's `0xL00000000000000007FFF800000000000` vs x86's `0xL0000000000000000FFFF800000000000` for the Constant folding test log_e_negative_infinity and a few others. I'm not sure if this is due to a target specific implementation of logf128 currently.

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


More information about the llvm-commits mailing list