[PATCH] D114162: [X86][clang] Enable floating-point type for -mno-x87 option on 32-bits

Andrew Savonichev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 19 01:11:04 PST 2021


asavonic added inline comments.


================
Comment at: clang/lib/Basic/Targets/X86.cpp:385
 
-  if (!HasX87) {
-    if (LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
-      HasLongDouble = false;
-    if (getTriple().getArch() == llvm::Triple::x86)
-      HasFPReturn = false;
-  }
+  if (!HasX87 && getTriple().getArch() == llvm::Triple::x86_64 &&
+      LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
----------------
I see that D112143 changed the ABI so that FP return values do not use x87 registers on i386. Therefore HasFPReturn flag can be removed.

However, operations with long double (x87 80-bit) should still be unsupported on both targets, because IIRC there is no SSE equivalent for them. GCC compiles them as soft-fp when -mno-x87 is set, but I haven't found 80-bit soft-fp implementation in LLVM.
```
long double baz(long double a, long double b) {
    return a + b;
}
```

```
baz:
   [...]
   call  __addxf3
```
For some reason GCC only does this for for i386 target, for x86_64 it just emits the diagnostic about disabled x87.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114162/new/

https://reviews.llvm.org/D114162



More information about the cfe-commits mailing list