Jason Hafer via llvm-dev
2021-Mar-05 02:46 UTC
[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/8907233e/attachment.html>
Craig Topper via llvm-dev
2021-Mar-05 06:24 UTC
[llvm-dev] Is it legal to pass a half by value on x86_64?
I'm not sure how robust the half support is on X86, clang should never generate it. I believe in llvm 11 it changed to pass in the lower 16 bits of an integer register instead of in a float register. What does "incorrect math operations" mean? We're emulating half precision with floats and a conversion function, I don't think it will always match exactly with what native half would do. Do you have a more complete IR file for Windows that I can take a look at? ~Craig On Thu, Mar 4, 2021 at 9:45 PM Jason Hafer via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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 > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210304/85c43dc3/attachment.html>
Wang, Pengfei via llvm-dev
2021-Mar-05 06:28 UTC
[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/3f7e2507/attachment.html>