[PATCH] D130718: [compiler-rt] [builtins] Detect _Float16 support at compile time

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 18:37:02 PDT 2022


pengfei added a comment.

In D130718#3688103 <https://reviews.llvm.org/D130718#3688103>, @dim wrote:

> In D130718#3686439 <https://reviews.llvm.org/D130718#3686439>, @pengfei wrote:
>
>> @kparzysz reminded me. This is not the right direction to solve the problem. The ABI of runtime libraries should be constant rather than changing with different features. Imagining a program may be built with or without `SSE2` and linked with the same runtime. Another problem is compatibility with libgcc. Using `uint16_t` is not compatible with libgcc anymore.
>>
>> Fortunately, LLVM codegen (unfortunately Darwin isn't) was using `__gnu_h2f_ieee/__gnu_f2h_ieee` before the change https://godbolt.org/z/GnrT5vGr1. So an easy way to solve the problem is always assign `-msse2` when build `extendhftf2/trunctfhf2`.
>>
>> I have a patch D128872 <https://reviews.llvm.org/D128872> for Darwin targets, I hope we can put it into the 15.x release.
>
> If this is the case, then maybe the whole commit that introduced the use of `_Float16` (i.e. rG655ba9c8a1d22075443711cc749f0b032e07adee <https://reviews.llvm.org/rG655ba9c8a1d22075443711cc749f0b032e07adee>) should be reverted *again*?  (It's already titled 'Reland "Reland "Reland "Reland "[X86][RFC] Enable _Float16 type support on X86 following the psABI""""', so relanding it One More Time shouldn't be that difficult ;))

It is nonsense to take the revert times as a reason.

> That said, rG655ba9c8a1d22075443711cc749f0b032e07adee <https://reviews.llvm.org/rG655ba9c8a1d22075443711cc749f0b032e07adee>'s description also says "following the psABI" so maybe this is actually going to improve ABI compatibility?

The psABI refers in particular to https://gitlab.com/x86-psABIs. There're some instruction limitations to make us only support `_Float16` for SSE2 and up, see the discussion https://groups.google.com/g/llvm-dev/c/k5WLPVGSeWU. And if you disable `SSE2`, you will get error on GCC too https://godbolt.org/z/33v7r9noP.

That said, build and provide the FP16 runtime without SSE2 is out of the scope of psABI. As for a general ABI compatibility, e.g., keeping the same calling conversion as pre rG655ba9c <https://reviews.llvm.org/rG655ba9c8a1d22075443711cc749f0b032e07adee> in cases without SSE2, this patch also doesn't help much, because for them we use `__gnu_h2f_ieee/__gnu_f2h_ieee` rather than `extendhftf2/trunctfhf2` (except for Darwin).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130718/new/

https://reviews.llvm.org/D130718



More information about the llvm-commits mailing list