[all-commits] [llvm/llvm-project] ee5aaa: [RISCV][test] Add additional RUN lines to half-con...
Alex Bradbury via All-commits
all-commits at lists.llvm.org
Fri Jun 30 08:42:26 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ee5aaa8e6c3f77925ca92f28cb961c0804986dd7
https://github.com/llvm/llvm-project/commit/ee5aaa8e6c3f77925ca92f28cb961c0804986dd7
Author: Alex Bradbury <asb at igalia.com>
Date: 2023-06-30 (Fri, 30 Jun 2023)
Changed paths:
M llvm/test/CodeGen/RISCV/half-convert.ll
Log Message:
-----------
[RISCV][test] Add additional RUN lines to half-convert.ll in preparation for D151824
There wasn't previous coverage for rv32id-ilp32, rv64id-lp64,
rv32id-ilp32d, or rv64id-lp64d. This is needed as D151284 fixes a bug
related to the ABI used for libcalls for fp<->fp16 conversion when hard
FP support is present.
Commit: 5ba40c7be35679a26d7b2c29affaad09aabf5e22
https://github.com/llvm/llvm-project/commit/5ba40c7be35679a26d7b2c29affaad09aabf5e22
Author: Alex Bradbury <asb at igalia.com>
Date: 2023-06-30 (Fri, 30 Jun 2023)
Changed paths:
M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
M llvm/test/CodeGen/RISCV/calling-conv-half.ll
M llvm/test/CodeGen/RISCV/copysign-casts.ll
M llvm/test/CodeGen/RISCV/fp16-promote.ll
M llvm/test/CodeGen/RISCV/fpclamptosat.ll
M llvm/test/CodeGen/RISCV/half-convert.ll
M llvm/test/CodeGen/RISCV/libcall-tail-calls.ll
M llvm/test/CodeGen/RISCV/rvv/fpclamptosat_vec.ll
M llvm/test/CodeGen/RISCV/rvv/pr63596.ll
Log Message:
-----------
[RISCV] Custom lower FP_TO_FP16 and FP16_TO_FP to correct ABI of of libcall
As introduced in D99148, RISC-V uses the softPromoteHalf legalisation
for fp16 values without zfh, with logic ensuring that f16 values are
passed in lower bits of FPRs (see D98670) when F or D support is
present. This legalisation produces ISD::FP_TO_FP16 and ISD::FP16_TO_FP
nodes which (as described in ISDOpcodes.h) provide a "semi-softened
interface for dealing with f16 (as an i16)". i.e. the return type of the
FP_TO_FP16 is an integer rather than a float (and the arg of FP16_TO_FP
is an integer). The remainder of the description focuses primarily on
FP_TO_FP16 for ease of explanation.
FP_TO_FP16 is lowered to a libcall to `__truncsfhf2 (float)` or
`__truncdfhf2 (double)`. As of D92241, `_Float16` is used as the return
type of these libcalls if the host compiler accepts `_Float16` in a test
input (i.e. dst_t is set to `_Float16`). `_Float16` is enabled for the
RISC-V target as of D105001 and so the return value should be passed in
an FPR on hard float ABIs.
This patch fixes the ABI issue in what appears to be a minimally
invasive way - leaving the softPromoteHalf logic undisturbed, and
lowering FP_TO_FP16 to an f32-returning libcall, converting its result
to an XLen integer value.
As can be seen in the test changes, the custom lowering for FP16_TO_FP
means the libcall is no longer tail-callable.
Although this patch fixes the issue, there are two open items:
* Redundant fmv.x.w and fmv.w.x pairs are now somtimes produced during
lowering (not a correctness issue).
* Now coverage for STRICT variants of FP16 conversion opcodes.
Differential Revision: https://reviews.llvm.org/D151284
Compare: https://github.com/llvm/llvm-project/compare/b7e8a55a83bf...5ba40c7be356
More information about the All-commits
mailing list