[fpc-devel] I've asked this before, but perhaps I wasn't specific enough that time: what do I *personally*, specifically need to do to ensure that a native Windows 64-bit build winds up on the FPC website for the next release?
Sven Barth
pascaldragon at googlemail.com
Fri Jan 14 07:27:38 CET 2022
Am 14.01.2022 um 03:15 schrieb Ben Grasset via fpc-devel:
> On Thu, Jan 13, 2022 at 9:48 AM Nikolay Nikolov via fpc-devel
> <fpc-devel at lists.freepascal.org> wrote:
>
> What do other win64 compilers do? Do they generate x87 FPU code
> for 64-bit Windows?
>
>
> Yes. Given the following:
>
> #include <stdio.h>
>
> long double do_three(long double x, long double y, long double z) {
> return (((x * x) / y) + z);
> }
>
> int main () {
> printf("%d\n", sizeof(long double));
> printf("%.19Lf\n", do_three(9.4567575785454772685L,
> 2.1211991522332311497L, 16.1216453784376343456L));
> }
>
> GCC 11.2 produces this assembly with "gcc -O3 -march=native -S
> test.c" on 64-bit Windows 10:
>
> do_three:
> .seh_endprologue
> fldt (%rdx)
> fldt (%r8)
> fldt (%r9)
> fxch %st(2)
> movq %rcx, %rax
> fmul %st(0), %st
> fdivp %st, %st(1)
> faddp %st, %st(1)
> fstpt (%rcx)
> ret
> .seh_endproc
>
> and Clang 13.0 produces this with the same command line arguments passed:
>
> do_three: # @do_three
> # %bb.0:
> movq %rcx, %rax
> fldt (%rdx)
> fldt (%r8)
> fldt (%r9)
> fxch %st(2)
> fmul %st, %st(0)
> fdivp %st, %st(1)
> faddp %st, %st(1)
> fstpt (%rcx)
> retq
>
> Running the program prints this with both compilers:
>
> 16
> 58.2818846964779790909
>
> So the answer to Mattias's question about C compilers from before is
> "they just directly support it on Windows".
For MSVC it's different:
=== code begin ===
; Function compile flags: /Ogtpy
; File C:\Users\Sven\source\repos\floattest\main.cpp
; COMDAT ?do_three@@YAOOOO at Z
_TEXT SEGMENT
x$ = 8
y$ = 16
z$ = 24
?do_three@@YAOOOO at Z PROC ; do_three, COMDAT
; 4 : return (((x * x) / y) + z);
00000 f2 0f 59 c0 mulsd xmm0, xmm0
00004 f2 0f 5e c1 divsd xmm0, xmm1
00008 f2 0f 58 c2 addsd xmm0, xmm2
; 5 : }
0000c c3 ret 0
?do_three@@YAOOOO at Z ENDP ; do_three
_TEXT ENDS
=== code end ===
=== output begin ===
8
58.2818846964779808673
=== output end ===
(though to be fair it does the same on 32-bit as well)
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20220114/57897724/attachment.htm>
More information about the fpc-devel
mailing list