[PATCH] D99148: [RISCV] Use softPromoteHalf legalization for fp16 without Zfh rather than PromoteFloat.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 22 23:53:53 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: asb, luismarques, kito-cheng, HsiangKai, evandro.
Herald added subscribers: StephenFan, vkmr, frasercrmck, apazos, sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

The default legalization strategy is PromoteFloat which keeps
half in single precision format through multiple floating point
operations. Conversion to/from float is done at loads, stores,
bitcasts, and other places that care about the exact size being 16
bits.

This patches switches to the alternative method softPromoteHalf.
This aims to keep the type in 16-bit format between every operation.
So we promote to float and immediately round for any arithmetic
operation. This should be closer to the IR semantics since we
are rounding after each operation and not accumulating extra
precision across multiple operations. X86 is the only other
target that enables this today. See https://reviews.llvm.org/D73749

I had to update getRegisterTypeForCallingConv to force f16 to
use f32 when the F extension is enabled. This way we can still
pass it in the lower bits of an FPR for ilp32f and lp64f ABIs.
The softPromoteHalf would otherwise always give i16 as the
argument type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99148

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/test/CodeGen/RISCV/calling-conv-half.ll
  llvm/test/CodeGen/RISCV/copysign-casts.ll
  llvm/test/CodeGen/RISCV/fp16-promote.ll
  llvm/test/CodeGen/RISCV/half-bitmanip-dagcombines.ll
  llvm/test/CodeGen/RISCV/rv32i-rv64i-half.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99148.332543.patch
Type: text/x-patch
Size: 21415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210323/247d0eb5/attachment.bin>


More information about the llvm-commits mailing list