<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hi Craig,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I am sorry for my poor example, probably better to take me out of the middle.<br>
I have attached the complete IR for the example on which I am working.  c2_foo() is where we break down.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Cheers.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
JP</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Craig Topper <craig.topper@gmail.com><br>
<b>Sent:</b> Friday, March 5, 2021 1:23 PM<br>
<b>To:</b> Wang, Pengfei <pengfei.wang@intel.com><br>
<b>Cc:</b> Jason Hafer <jhafer@mathworks.com>; llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: Is it legal to pass a half by value on x86_64?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>For this code the half store from the IR appears to have been removed because it is a local variable that was never read from. The store that says "4-byte Spill" is a different store and seems to be some -O0 artifact. With -O2 the whole thing becomes just
 a ret.</div>
<div><br>
</div>
<div><span style="color:rgb(0,0,0); font-size:15px">define void @foo(i8, i8, i8, i8, half) {</span>
<div style="color:rgb(0,0,0); font-size:15px">; CHECK-I686:    callq __gnu_f2h_ieee</div>
<span class="x_gmail-im" style="color:rgb(80,0,80); font-size:15px">
<div><br>
</div>
<div>  %6 = alloca half</div>
<div>  store half %4, half* %6, align 1</div>
</span>
<div style="color:rgb(0,0,0); font-size:15px">  ret void</div>
<span style="color:rgb(0,0,0); font-size:15px">}</span><br style="color:rgb(0,0,0); font-size:15px">
<br style="color:rgb(0,0,0); font-size:15px">
<span style="color:rgb(0,0,0); font-size:15px">x86_64-pc-windows gives:</span><br style="color:rgb(0,0,0); font-size:15px">
<span style="color:rgb(0,0,0); font-size:15px">push rax</span>
<div style="color:rgb(0,0,0); font-size:15px">.seh_stackalloc 8</div>
<div style="color:rgb(0,0,0); font-size:15px">.seh_endprologue</div>
<div style="color:rgb(0,0,0); font-size:15px">movss xmm0, dword ptr [rsp + 48] # xmm0 = mem[0],zero,zero,zero</div>
<div style="color:rgb(0,0,0); font-size:15px">movss dword ptr [rsp + 4], xmm0 # 4-byte Spill</div>
<div style="color:rgb(0,0,0); font-size:15px">pop rax</div>
<div style="color:rgb(0,0,0); font-size:15px">ret</div>
<div style="color:rgb(0,0,0); font-size:15px">.seh_handlerdata</div>
<div style="color:rgb(0,0,0); font-size:15px">.text</div>
<div style="color:rgb(0,0,0); font-size:15px">.seh_endproc</div>
</div>
<div style="color:rgb(0,0,0); font-size:15px"><br>
</div>
<div style="color:rgb(0,0,0); font-size:15px"><br>
</div>
<div style="color:rgb(0,0,0); font-size:15px">As an experiment, I tried this which does produce a call to __gnu_f2h_ieee on windows with llvm 8.0 and llvm 10.0</div>
<div style="color:rgb(0,0,0); font-size:15px"><br>
</div>
<div style="color:rgb(0,0,0); font-size:15px">
<div style="background-color:rgb(255,255,254); font-family:"Consolas, "">
<div><span style="color:rgb(0,0,255)">define</span> <span style="color:rgb(0,128,128)">
void</span> <span style="color:rgb(0,17,136)">@foo</span>(<span style="color:rgb(0,128,128)">half</span>*,
<span style="color:rgb(0,128,128)">i8</span>, <span style="color:rgb(0,128,128)">
i8</span>, <span style="color:rgb(0,128,128)">half</span>) {</div>
<div>store <span style="color:rgb(0,128,128)">half</span> <span style="color:rgb(0,17,136)">
%3</span>, <span style="color:rgb(0,128,128)">half</span>* <span style="color:rgb(0,17,136)">
%0</span>, <span style="color:rgb(0,0,255)">align</span> <span style="color:rgb(9,134,88)">
1</span></div>
<div>ret <span style="color:rgb(0,128,128)">void</span></div>
<div>}</div>
</div>
</div>
<div style="color:rgb(0,0,0); font-size:15px"><br>
</div>
<div><br>
</div>
<div>For this assembly you provided, I don't see any reads from xmm0, or any word stores. So it's hard for me to determine what might be going wrong. Can provide the assembly where xmm0 is eventually used?</div>
<div><br>
</div>
<div>
<div style="color:rgb(0,0,0); font-size:15px">mov rax, qword ptr [rsp + 424]</div>
<div style="color:rgb(0,0,0); font-size:15px"> movss xmm0, dword ptr [rsp + 416] # xmm0 = mem[0],zero,zero,zero  # <-- moves the data like it wants to convert but never does</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 344], rcx</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 336], rdx</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 328], r8</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 320], r9</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 304], 0</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 296], 0</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 288], 0</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 280], 0</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov rcx, qword ptr [rsp + 328]</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 272], rcx</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov rcx, qword ptr [rsp + 328]</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov rcx, qword ptr [rcx + 8]</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 264], rcx</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov rcx, qword ptr [rsp + 336]</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov rcx, qword ptr [rcx + 56]</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 256], rcx</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov dword ptr [rsp + 312], 0</div>
<div style="color:rgb(0,0,0); font-size:15px"> mov qword ptr [rsp + 248], rax # 8-byte Spill</div>
<span style="color:rgb(0,0,0); font-size:15px"> movss dword ptr</span><br>
</div>
<div><br>
</div>
<br clear="all">
<div>
<div dir="ltr" class="x_gmail_signature">~Craig</div>
</div>
<br>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Fri, Mar 5, 2021 at 6:46 AM Wang, Pengfei <<a href="mailto:pengfei.wang@intel.com">pengfei.wang@intel.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div lang="EN-US" style="">
<div class="x_gmail-m_2196751435081469443WordSection1">
<p class="x_MsoNormal"><span style="font-size:12pt; color:rgb(31,73,125)">Hi Jason,<u></u><u></u></span></p>
<p class="x_MsoNormal"><span style="font-size:12pt; color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="x_MsoNormal"><span style="font-size:12pt; color:rgb(31,73,125)">The different behavior between Linux and Windows comes form the difference of the calling conversion. Windows uses 4 registers for arguments passing which Linux uses 6.<u></u><u></u></span></p>
<p class="x_MsoNormal"><span style="font-size:12pt; color:rgb(31,73,125)"><a href="https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-160#parameter-passing" target="_blank">https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-160#parameter-passing</a><u></u><u></u></span></p>
<p class="x_MsoNormal"><span style="font-size:12pt; color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div>
<p class="x_MsoNormal"><span style="color:rgb(31,73,125)">Thanks<u></u><u></u></span></p>
<p class="x_MsoNormal"><span style="color:rgb(31,73,125)">Pengfei<u></u><u></u></span></p>
</div>
<p class="x_MsoNormal"><span style="font-size:12pt; color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div>
<div style="border-right:none; border-bottom:none; border-left:none; border-top:1pt solid rgb(225,225,225); padding:3pt 0in 0in">
<p class="x_MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>Jason Hafer via llvm-dev<br>
<b>Sent:</b> Friday, March 5, 2021 10:21 PM<br>
<b>To:</b> Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] Is it legal to pass a half by value on x86_64?<u></u><u></u></p>
</div>
</div>
<p class="x_MsoNormal"><u></u> <u></u></p>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black; background:white">Hi All,</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black">Thank you very much for all the great information.  This is awesome! <u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black">To circle back on Craig's questions.<u></u><u></u></span></p>
</div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black; background:white">I did notice LLVM 11 behave very differently.</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black; background:white">** Per: </span><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">What does "incorrect math operations"
 mean? </span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">The half is passed to the function as a float.  The function does operations with other half numbers.  On Windows
 when we don't get the float to half conversation the input is always truncated to 0.0.</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">** Per: "Do you have a more complete IR file for Windows that I can take a look at?"</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin-bottom:12pt; background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">I can get you our IR if you want, but I think it is more convoluted than required.  I was working
 on a unit test and I think all one needs to see the anomaly is:</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">define void @foo(i8, i8, i8, i8, half) {
<u></u><u></u></span></p>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">; CHECK-I686:    callq __gnu_f2h_ieee<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  %6 = alloca half<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  store half %4, half* %6, align 1<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  ret void<u></u><u></u></span></p>
</div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">}<br>
<br>
x86_64-pc-windows gives:<br>
push rax <u></u><u></u></span></p>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_stackalloc 8<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_endprologue<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">movss xmm0, dword ptr [rsp + 48] # xmm0 = mem[0],zero,zero,zero<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">movss dword ptr [rsp + 4], xmm0 # 4-byte Spill<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">pop rax<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">ret<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_handlerdata<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.text<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_endproc<u></u><u></u></span></p>
</div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black">What I find extremely interesting is the behavior seems has something to do with the stack?  For dropping the inputs by one then even Windows will generate the conversion.<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">define void @foo(i8, i8, i8, half) {
<u></u><u></u></span></p>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">; CHECK-I686:    callq __gnu_f2h_ieee<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  %5 = alloca half<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  store half %3, half* %5, align 1<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  ret void<u></u><u></u></span></p>
</div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">}</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">x86_64-pc-windows gives:</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">sub rsp, 40<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_stackalloc 40<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_endprologue<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">movabs rax, offset __gnu_f2h_ieee<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">movaps xmm0, xmm3<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">call rax<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">mov word ptr [rsp + 38], ax<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">add rsp, 40<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">ret<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_handlerdata<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.text<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">.seh_endproc<u></u><u></u></span></p>
</div>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">** If interested, here is a dissection of our real asm.<br>
For both Windows and Linux our IR calls c2_foo() with a half(2): <u></u><u></u></span></p>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">...<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">call void @c2_foo(i8* %S_6, [21 x i8*]* %ptr_gvar_instance_7, %emlrtStack* %c2_b_st_, [18 x float]* @15, half 0xH4000,
 [18 x i8]* %t10)<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">They both register this in c2_foo as:<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">...<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  %c2_in2_ = alloca half<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">  store half %c2_in2, half* %c2_in2_, align 1<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">When we compile them, they both send 0x40000000 to c2_foo (a single).<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">The Linux c2_foo() asm addresses this with a float2half conversion:<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">...<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 448], rdi<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 440], rsi<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 432], rdx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 424], rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> movabs rcx, offset __gnu_f2h_ieee     # <---Convert Here<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 336], r8 # 8-byte Spill<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> call rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov word ptr [rsp + 422], ax<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rcx, qword ptr [rsp + 336] # 8-byte Reload<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 408], rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 392], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 384], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 376], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 368], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rdx, qword ptr [rsp + 432]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 360], rdx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rdx, qword ptr [rsp + 432]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rdx, qword ptr [rdx + 8]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 352], rdx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rdx, qword ptr [rsp + 440]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rdx, qword ptr [rdx + 56]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 344], rdx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov dword ptr [rsp + 400], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> jmp .LBB9_9<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">The Windows c2_foo() asm is missing this conversion but treats the value as if it has been converted.<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white">...<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rax, qword ptr [rsp + 424]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> movss xmm0, dword ptr [rsp + 416] # xmm0 = mem[0],zero,zero,zero  # <-- moves the data like it wants to convert
 but never does<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 344], rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 336], rdx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 328], r8<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 320], r9<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 304], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 296], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 288], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 280], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rcx, qword ptr [rsp + 328]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 272], rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rcx, qword ptr [rsp + 328]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rcx, qword ptr [rcx + 8]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 264], rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rcx, qword ptr [rsp + 336]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov rcx, qword ptr [rcx + 56]<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 256], rcx<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov dword ptr [rsp + 312], 0<u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> mov qword ptr [rsp + 248], rax # 8-byte Spill<u></u><u></u></span></p>
</div>
<p class="x_MsoNormal" style="margin-bottom:12pt; background:white"><span style="font-size:11.5pt; font-family:"Segoe UI",sans-serif; color:black; background:white"> movss dword ptr<br>
<br>
</span><span style="font-size:12pt; color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12pt; color:black"><u></u> <u></u></span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_gmail-m_2196751435081469443divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Wang, Pengfei <<a href="mailto:pengfei.wang@intel.com" target="_blank">pengfei.wang@intel.com</a>><br>
<b>Sent:</b> Friday, March 5, 2021 7:30 AM<br>
<b>To:</b> Sjoerd Meijer <<a href="mailto:Sjoerd.Meijer@arm.com" target="_blank">Sjoerd.Meijer@arm.com</a>>; Jason Hafer <<a href="mailto:jhafer@mathworks.com" target="_blank">jhafer@mathworks.com</a>><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> RE: Is it legal to pass a half by value on x86_64?</span> <u></u><u></u></p>
<div>
<p class="x_MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)">I guess it’s designed for language portability. You can use this type across different platforms. Nevertheless, I’m not a FE expert, so I cannot think out
 other intentions.</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)">The _Float16 is a primitive type in the latest x86 ABI, but there’s no X86 target that supports it yet. So you cannot use it on X86 by now. I think that’s
 the difference from __fp16 and why should use it.</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)">We also have some discussion here.
<a href="https://reviews.llvm.org/D97318" target="_blank">
https://reviews.llvm.org/D97318</a></span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="color:rgb(31,73,125)">Thanks</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="color:rgb(31,73,125)">Pengfei</span><u></u><u></u></p>
</div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div>
<div style="border-right:none; border-bottom:none; border-left:none; border-top:1pt solid rgb(225,225,225); padding:3pt 0in 0in">
<p class="x_gmail-m_2196751435081469443xmsonormal"><b>From:</b> Sjoerd Meijer <<a href="mailto:Sjoerd.Meijer@arm.com" target="_blank">Sjoerd.Meijer@arm.com</a>>
<br>
<b>Sent:</b> Friday, March 5, 2021 5:49 PM<br>
<b>To:</b> Jason Hafer <<a href="mailto:jhafer@mathworks.com" target="_blank">jhafer@mathworks.com</a>>; Wang, Pengfei <<a href="mailto:pengfei.wang@intel.com" target="_blank">pengfei.wang@intel.com</a>><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: Is it legal to pass a half by value on x86_64?<u></u><u></u></p>
</div>
</div>
<p class="x_gmail-m_2196751435081469443xmsonormal"> <u></u><u></u></p>
<blockquote style="border-top:none; border-right:none; border-bottom:none; border-left:2.25pt solid rgb(200,200,200); padding:0in 0in 0in 6pt; margin-left:4.8pt; margin-top:5pt; margin-bottom:5pt">
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:rgb(31,73,125); background:white">__fp16 is a pure storage format. You cannot pass it by value, because only<span class="x_gmail-m_2196751435081469443xapple-converted-space"> </span></span><span style="font-size:12pt; color:black"><a href="https://gitlab.com/x86-psABIs/x86-64-ABI" target="_blank">ABI</a></span><span class="x_gmail-m_2196751435081469443xapple-converted-space"><span style="font-size:12pt; color:rgb(31,73,125); background:white"> </span></span><span style="font-size:12pt; color:rgb(31,73,125); background:white">permissive
 types can be passed by value while __fp16 is not one of them.</span><u></u><u></u></p>
</div>
</blockquote>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:black; background:white">Yep. Any specific reason to use a pure storage format? The native type is _Float16 and would give some benefits, but this is not yet supported on
 x86, see also:</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal" style="margin-bottom:12pt"><u></u> <u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal" style="margin-bottom:12pt"><span style="font-size:12pt; color:rgb(31,73,125); background:white"><a href="https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point" target="_blank">https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point</a></span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"><span style="font-size:12pt; color:black">Cheers,<br>
Sjoerd.</span><u></u><u></u></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="1" width="98%" align="center">
</div>
<div id="x_gmail-m_2196751435081469443x_divRplyFwdMsg">
<p class="x_gmail-m_2196751435081469443xmsonormal"><b><span style="color:black">From:</span></b><span style="color:black"> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Wang, Pengfei
 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Sent:</b> 05 March 2021 06:28<br>
<b>To:</b> Jason Hafer <<a href="mailto:jhafer@mathworks.com" target="_blank">jhafer@mathworks.com</a>><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] Is it legal to pass a half by value on x86_64?</span>
<u></u><u></u></p>
<div>
<p class="x_gmail-m_2196751435081469443xmsonormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)">Hi Jason,</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)">__fp16 is a pure storage format. You cannot pass it by value, because only
<a href="https://gitlab.com/x86-psABIs/x86-64-ABI" target="_blank">
ABI</a> permissive types can be passed by value while __fp16 is not one of them.</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)"> </span><u></u><u></u></p>
<ul type="disc" style="margin-top:0in">
<li class="x_gmail-m_2196751435081469443xxmsolistparagraph" style="color:rgb(31,73,125); margin-top:0in; margin-bottom:0in">
<span style="font-size:12pt; color:black">if "<span style="background:white">define void @foo(i8, i8, i8, i8, half) " is even legal to use</span></span><u></u><u></u></li></ul>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)">half as a target independent type is legal for LLVM. It’s not legal for unsupported target like X86. The behavior depends on how we lowering it. But I don’t
 know why there’s differences between Linux and Windows. Maybe because “__gnu_f2h_ieee” is a Linux only function?</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="color:rgb(31,73,125)">Thanks</span><u></u><u></u></p>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="color:rgb(31,73,125)">Pengfei</span><u></u><u></u></p>
</div>
<p class="x_gmail-m_2196751435081469443xxmsonormal"><span style="font-size:12pt; color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div>
<div style="border-right:none; border-bottom:none; border-left:none; border-top:1pt solid rgb(225,225,225); padding:3pt 0in 0in">
<p class="x_gmail-m_2196751435081469443xxmsonormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>Jason Hafer via llvm-dev<br>
<b>Sent:</b> Friday, March 5, 2021 10:46 AM<br>
<b>To:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Cc:</b> Jason Hafer <<a href="mailto:jhafer@mathworks.com" target="_blank">jhafer@mathworks.com</a>><br>
<b>Subject:</b> [llvm-dev] Is it legal to pass a half by value on x86_64?<u></u><u></u></p>
</div>
</div>
<p class="x_gmail-m_2196751435081469443xxmsonormal"> <u></u><u></u></p>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">Hello,</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">I am attempting to understand an anomaly I am seeing when dealing with half on Windows and could use some help.</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">Using LLVM 8 or 10, if I have IR of the flavor below:<br>
define void @foo(i8, i8, i8, i8, half) { </span><u></u><u></u></p>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">  %6 = alloca half</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">  store half %4, half* %6, align 1</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">  ...</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">  ret void</span><u></u><u></u></p>
</div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">}</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">Using x86_64-pc-linux, we convert the float passed in with __gnu_f2h_ieee.</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">Using x86_64-pc-windows I do not get the conversion, so we end up with incorrect math operations.</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">While investigating I noticed clang gave me the error below:</span><u></u><u></u></p>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:10.5pt; font-family:"Segoe UI",sans-serif; color:black">error: parameters cannot have __fp16 type; did you forget * ?<br>
void foo(int dc1, int dc2,int dc3,int dc4, __fp16 in)</span><u></u><u></u></p>
</div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">So, this got me wondering if "<span style="background:white">define void @foo(i8, i8, i8, i8, half) " is even legal to use or if I should
 rather pass by ref?  I have yet to find documentation to convince me one way or the other.  Thus, I was hoping someone here might be able to shed some light on the issue.</span></span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">Thank you in advance!</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">Cheers,</span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black"> </span><u></u><u></u></p>
</div>
<div>
<p class="x_gmail-m_2196751435081469443xxmsonormal" style="background:white"><span style="font-size:12pt; color:black">JP</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>