[PATCH] D98895: [X86][Draft] Disable long double type for -mno-x87 option
Pengfei Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 25 07:07:57 PDT 2021
pengfei added inline comments.
================
Comment at: clang/test/Sema/x86-no-x87.c:2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-linux-gnu -target-feature -x87
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-windows-msvc -target-feature -x87 -DNOERROR
----------------
asavonic wrote:
> pengfei wrote:
> > Should i686 expect no error like GCC?
> GCC seems to fallback to soft-float for i686 if -mno-80387 is used:
>
> long double orig(long double x, long double y)
> {
> long double z = x + y;
> if (z < 0.0)
> return z;
> else
> return 0.0;
> }
>
> i686-linux-gnu-gcc-8 -c -S -mno-80387 -O3:
> call __addxf3 at PLT
> [...]
> call __ltxf2 at PLT
> addl $32, %esp
> testl %eax, %eax
> js .L3
> xorl %esi, %esi
> xorl %edi, %edi
> xorl %ebp, %ebp
> .L3:
> addl $12, %esp
> movl %esi, %eax
> movl %edi, %edx
> movl %ebp, %ecx
> popl %ebx
> popl %esi
> popl %edi
> popl %ebp
> ret
>
> This looks like a different ABI.
> X87 instructions are not used, so no error is reported.
>
I found it's a bit complex for 32 bits.
1. i686 ABI specifies the return of floating point type must be put in %st0, so any FP type returning should be error out w/o x87.
2. GCC doesn't respect above ABI.
3. FP types are passed from stack, so a function like `void orig(long double x, long double y, long double *z)` should not be error out w/o x87.
x86_64 only uses ST registers when returning FP80.
Considering it is rare for case 3, I think we can ignore it this time, but I suggest we should add check for float and double on 32 bits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98895/new/
https://reviews.llvm.org/D98895
More information about the cfe-commits
mailing list