[all-commits] [llvm/llvm-project] fb34d5: Promote bf16 to f32 when the target doesn't suppor...
Benjamin Kramer via All-commits
all-commits at lists.llvm.org
Wed Jun 15 04:01:25 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fb34d531af953119593be74753b89baf99fbc194
https://github.com/llvm/llvm-project/commit/fb34d531af953119593be74753b89baf99fbc194
Author: Benjamin Kramer <benny.kra at googlemail.com>
Date: 2022-06-15 (Wed, 15 Jun 2022)
Changed paths:
M compiler-rt/lib/builtins/CMakeLists.txt
M compiler-rt/lib/builtins/fp_trunc.h
A compiler-rt/lib/builtins/truncsfbf2.c
M llvm/include/llvm/CodeGen/ISDOpcodes.h
M llvm/include/llvm/IR/RuntimeLibcalls.def
M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
M llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
M llvm/lib/CodeGen/TargetLoweringBase.cpp
M llvm/lib/Target/X86/X86ISelLowering.cpp
A llvm/test/CodeGen/X86/bfloat.ll
Log Message:
-----------
Promote bf16 to f32 when the target doesn't support it
This is modeled after the half-precision fp support. Two new nodes are
introduced for casting from and to bf16. Since casting from bf16 is a
simple operation I opted to always directly lower it to integer
arithmetic. The other way round is more complicated if you want to
preserve IEEE semantics, so it's handled by a new __truncsfbf2
compiler-rt builtin.
This is of course very bare bones, but sufficient to get a semi-softened
fadd on x86.
Possible future improvements:
- Targets with bf16 conversion instructions can now make fp_to_bf16 legal
- The software conversion to bf16 can be replaced by a trivial
implementation under fast math.
Differential Revision: https://reviews.llvm.org/D126953
Commit: 8bc0bb956421e02bc1a1797363e979655dd326d6
https://github.com/llvm/llvm-project/commit/8bc0bb956421e02bc1a1797363e979655dd326d6
Author: Benjamin Kramer <benny.kra at googlemail.com>
Date: 2022-06-15 (Wed, 15 Jun 2022)
Changed paths:
M compiler-rt/lib/builtins/CMakeLists.txt
A compiler-rt/lib/builtins/truncdfbf2.c
M llvm/include/llvm/IR/RuntimeLibcalls.def
M llvm/lib/CodeGen/TargetLoweringBase.cpp
M llvm/test/CodeGen/X86/bfloat.ll
Log Message:
-----------
Add a conversion from double to bf16
This introduces a new compiler-rt function `__truncdfbf2`.
Compare: https://github.com/llvm/llvm-project/compare/43e7ba649535...8bc0bb956421
More information about the All-commits
mailing list