[PATCH] D151436: [compiler-rt][SelectionDAG] Add extendbfsf2 libcall and use it for bf16 extends with soft FP
Alex Bradbury via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 06:04:44 PDT 2023
asb created this revision.
asb added reviewers: compnerd, bkramer, t.p.northover, arsenm, craig.topper.
Herald added subscribers: luke, wingo, Enna1, pmatos, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson, dberris.
Herald added a project: All.
asb requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay, wdng.
Herald added a project: LLVM.
Previously this resulted in an assert (reproducible on RISC-V with soft FP). The existing code path assumes a libcall is present, and adding the libcall seems like the easiest fix. This libcall _is_ provided by libgcc, which perhaps providing its own motivation for adding it here.
The legalisation code in LegalizeDAG lowers to an anyext and shift which might be an alternative. This would however be more invasive to support vs just adding an extra case to the existing libcall lowering logic, and these soft targets are likely not a target we care strongly about BF16 support beyond wanting some basic support for completeness.
I'm not able to convince myself that the anyext+shift lowering is always identical to the more elaborate extension performed by the libcall in all cases (and if so, why do the trunc and extend libcalls even exist?). though I'm not sure I can convince myself. I know @craig.topper was involved in a previous discussion on this so I'd appreciate your view.
https://reviews.llvm.org/D151436
Files:
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/extendbfsf2.c
compiler-rt/lib/builtins/fp_extend.h
llvm/include/llvm/IR/RuntimeLibcalls.def
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/test/CodeGen/RISCV/bfloat.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151436.525568.patch
Type: text/x-patch
Size: 7644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/6227138a/attachment.bin>
More information about the llvm-commits
mailing list