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

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 04:02:24 PDT 2024


chapuni wrote:

@davemgreen Thanks for your explanation of the background and I am sorry for bothering you.

> The two machines you mention (aarch64 on x86 and aarch64 on aarch64) I would expect should both have logf128 providing they are new enough (or fp128 would not be relevant for them).

In fact, my environment, (Ubuntu-20.04 glibc-2.31, gcc-9.4, libstdc++-9), didn't detect `HAS_LOGF128` on x86-64 clang but did on g++-9.4 and aarch64-clang. As my further investigation, `/usr/include/x86_64-linux-gnu/bits/floatn.h` has the condition;

```
/* Defined to 1 if the current compiler invocation provides a
   floating-point type with the IEEE 754 binary128 format, and this
   glibc includes corresponding *f128 interfaces for it.  The required
   libgcc support was added some time after the basic compiler
   support, for x86_64 and x86.  */
#if (defined __x86_64__                                                 \
     ? __GNUC_PREREQ (4, 3)                                             \
     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \
     &&  !defined(__CUDACC__)
# define __HAVE_FLOAT128 1
#else
# define __HAVE_FLOAT128 0
#endif
```

x86_64-clang doesn't set `__HAVE_FLOAT128=1` since clang pretends gcc-4.2.1.

For now, I hope logf128-specific behavior may be suppressed with CMake configuration.
Also ppc64 is incompatible.

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


More information about the llvm-commits mailing list