<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Am 14.01.2022 um 03:15 schrieb Ben
Grasset via fpc-devel:<br>
</div>
<blockquote type="cite"
cite="mid:CAL4d7Fiqoi7PmZndVEcVpcyM9Ga9n8z7EWmpHWjyi8sK1=YETg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">On Thu, Jan 13, 2022 at 9:48 AM Nikolay Nikolov
via fpc-devel <<a
href="mailto:fpc-devel@lists.freepascal.org"
moz-do-not-send="true" class="moz-txt-link-freetext">fpc-devel@lists.freepascal.org</a>>
wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_quote"> </div>
</div>
</blockquote>
What do other win64 compilers do? Do they generate x87 FPU
code for 64-bit Windows?<br>
</div>
</blockquote>
<div><br>
</div>
<div>Yes. Given the following:</div>
<div><br>
</div>
#include <stdio.h><br>
<br>
long double do_three(long double x, long double y, long double
z) {<br>
return (((x * x) / y) + z);<br>
}<br>
<br>
int main () {<br>
printf("%d\n", sizeof(long double));<br>
printf("%.19Lf\n", do_three(9.4567575785454772685L,
2.1211991522332311497L, 16.1216453784376343456L));<br>
<div>}</div>
<div><br>
</div>
<div> GCC 11.2 produces this assembly with "gcc -O3
-march=native -S test.c" on 64-bit Windows 10:</div>
<div><br>
</div>
<div>do_three:<br>
.seh_endprologue<br>
fldt (%rdx)<br>
fldt (%r8)<br>
fldt (%r9)<br>
fxch %st(2)<br>
movq %rcx, %rax<br>
fmul %st(0), %st<br>
fdivp %st, %st(1)<br>
faddp %st, %st(1)<br>
fstpt (%rcx)<br>
ret<br>
.seh_endproc<br>
</div>
<div><br>
</div>
<div>and Clang 13.0 produces this with the same command line
arguments passed:</div>
<div><br>
</div>
<div>do_three: # @do_three<br>
# %bb.0:<br>
movq %rcx, %rax<br>
fldt (%rdx)<br>
fldt (%r8)<br>
fldt (%r9)<br>
fxch %st(2)<br>
fmul %st, %st(0)<br>
fdivp %st, %st(1)<br>
faddp %st, %st(1)<br>
fstpt (%rcx)<br>
retq<br>
</div>
<div><br>
</div>
<div>Running the program prints this with both compilers:</div>
<div><br>
</div>
<div>16<br>
58.2818846964779790909<br>
</div>
<div><br>
</div>
<div>So the answer to Mattias's question about C compilers
from before is "they just directly support it on Windows".</div>
</div>
</div>
</blockquote>
<br>
For MSVC it's different:<br>
<br>
=== code begin ===<br>
<br>
; Function compile flags: /Ogtpy<br>
; File C:\Users\Sven\source\repos\floattest\main.cpp<br>
; COMDAT ?do_three@@YAOOOO@Z<br>
_TEXT SEGMENT<br>
x$ = 8<br>
y$ = 16<br>
z$ = 24<br>
?do_three@@YAOOOO@Z PROC ; do_three, COMDAT<br>
<br>
; 4 : return (((x * x) / y) + z);<br>
<br>
00000 f2 0f 59 c0 mulsd xmm0, xmm0<br>
00004 f2 0f 5e c1 divsd xmm0, xmm1<br>
00008 f2 0f 58 c2 addsd xmm0, xmm2<br>
<br>
; 5 : }<br>
<br>
0000c c3 ret 0<br>
?do_three@@YAOOOO@Z ENDP ; do_three<br>
_TEXT ENDS<br>
<br>
=== code end ===<br>
<br>
=== output begin ===<br>
<br>
8<br>
58.2818846964779808673<br>
<br>
=== output end ===<br>
<br>
(though to be fair it does the same on 32-bit as well)<br>
<br>
Regards,<br>
Sven<br>
</body>
</html>