[llvm-dev] Is it legal to pass a half by value on x86_64?
Sjoerd Meijer via llvm-dev
llvm-dev at lists.llvm.org
Fri Mar 5 01:49:10 PST 2021
__fp16 is a pure storage format. You cannot pass it by value, because only ABI<https://gitlab.com/x86-psABIs/x86-64-ABI> permissive types can be passed by value while __fp16 is not one of them.
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:
https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
Cheers,
Sjoerd.
________________________________
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Wang, Pengfei via llvm-dev <llvm-dev at lists.llvm.org>
Sent: 05 March 2021 06:28
To: Jason Hafer <jhafer at mathworks.com>
Cc: llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Is it legal to pass a half by value on x86_64?
Hi Jason,
__fp16 is a pure storage format. You cannot pass it by value, because only ABI<https://gitlab.com/x86-psABIs/x86-64-ABI> permissive types can be passed by value while __fp16 is not one of them.
* if "define void @foo(i8, i8, i8, i8, half) " is even legal to use
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?
Thanks
Pengfei
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Jason Hafer via llvm-dev
Sent: Friday, March 5, 2021 10:46 AM
To: llvm-dev at lists.llvm.org
Cc: Jason Hafer <jhafer at mathworks.com>
Subject: [llvm-dev] Is it legal to pass a half by value on x86_64?
Hello,
I am attempting to understand an anomaly I am seeing when dealing with half on Windows and could use some help.
Using LLVM 8 or 10, if I have IR of the flavor below:
define void @foo(i8, i8, i8, i8, half) {
%6 = alloca half
store half %4, half* %6, align 1
...
ret void
}
Using x86_64-pc-linux, we convert the float passed in with __gnu_f2h_ieee.
Using x86_64-pc-windows I do not get the conversion, so we end up with incorrect math operations.
While investigating I noticed clang gave me the error below:
error: parameters cannot have __fp16 type; did you forget * ?
void foo(int dc1, int dc2,int dc3,int dc4, __fp16 in)
So, this got me wondering if "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.
Thank you in advance!
Cheers,
JP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210305/7d556fac/attachment.html>
More information about the llvm-dev
mailing list