Page MenuHomePhabricator

[RFC][doc] Document that RISC-V's __fp16 has different behavior
Needs ReviewPublic

Authored by kito-cheng on Mar 5 2021, 12:13 AM.

Details

Summary

RISC-V has a draft extension for half-precision proposed last year[1],
so we think adding a new type for that would be great to make this
easier to use that extension.

We found there is _Float16 and __fp16 types are supported on GCC and
Clang, but _Float16 has C++ supporting issue on GCC site, so we think
support both type is a reasonable choice to us.

However we would like have slight different behavior for __fp16 other
than ACLE: The evaluation format of __fp16 set same as _Float16,
which means no promotion are performed if there is no hardware half-precision
supported.

The only concern to us is it's defined differnt with clang's document,
so we would put this RFC patch here, to make sure it's OK for make
__fp16 has differnt behavior between differnt targets.

This patch contain document change only, implementation would be in
another patches.

[1] https://github.com/riscv/riscv-isa-manual/pull/496
[2] https://github.com/riscv/riscv-elf-psabi-doc/pull/172

Co-authored-by: Evandro Menezes <evandro.menezes@sifive.com>

Diff Detail

Unit TestsFailed

TimeTest
70 msx64 debian > LLVM.CodeGen/X86/AMX::amx-low-intrinsics-no-amx-bitcast.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -mtriple=x86_64 -lower-amx-intrinsics /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll -S | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll
60 msx64 debian > LLVM.CodeGen/X86/AMX::amx-low-intrinsics.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -mtriple=x86_64 -lower-amx-intrinsics /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll -S | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll

Event Timeline

kito-cheng created this revision.Mar 5 2021, 12:13 AM
kito-cheng requested review of this revision.Mar 5 2021, 12:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2021, 12:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
SjoerdMeijer added a comment.EditedMar 5 2021, 3:47 AM

However we would like have slight different behavior for fp16 other than ACLE: The evaluation format of fp16 set same as _Float16, which means no promotion are performed if there is no hardware half-precision supported.

Well, this is really problematic, because you're giving __fp16 a different semantics, you're defining it to behave as _Float16.
Redefining an existing type, let it differentiate from other targets can never be a good thing.
I don't see how this is going to help anyone.