[PATCH] D118420: [AArch64] Add isel for bitcasting between bfloat and half types.
Paul Walker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 27 16:39:53 PST 2022
paulwalker-arm created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
paulwalker-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118420
Files:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/bf16.ll
Index: llvm/test/CodeGen/AArch64/bf16.ll
===================================================================
--- llvm/test/CodeGen/AArch64/bf16.ll
+++ llvm/test/CodeGen/AArch64/bf16.ll
@@ -82,3 +82,17 @@
ret { <8 x bfloat>, <8 x bfloat>* } %res
}
+
+define bfloat @test_bitcast_halftobfloat(half %a) nounwind {
+; CHECK-LABEL: test_bitcast_halftobfloat:
+; CHECK-NEXT: ret
+ %r = bitcast half %a to bfloat
+ ret bfloat %r
+}
+
+define half @test_bitcast_bfloattohalf(bfloat %a) nounwind {
+; CHECK-LABEL: test_bitcast_bfloattohalf:
+; CHECK-NEXT: ret
+ %r = bitcast bfloat %a to half
+ ret half %r
+}
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -7550,6 +7550,9 @@
def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
(COPY_TO_REGCLASS V64:$Vn, GPR64)>;
+def : Pat<(f16 (bitconvert (bf16 FPR16:$src))), (f16 FPR16:$src)>;
+def : Pat<(bf16 (bitconvert (f16 FPR16:$src))), (bf16 FPR16:$src)>;
+
let Predicates = [IsLE] in {
def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -3746,6 +3746,10 @@
if (OpVT != MVT::f16 && OpVT != MVT::bf16)
return SDValue();
+ // Bitcasts between f16 and bf16 are legal.
+ if (ArgVT == MVT::f16 || ArgVT == MVT::bf16)
+ return Op;
+
assert(ArgVT == MVT::i16);
SDLoc DL(Op);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118420.403836.patch
Type: text/x-patch
Size: 1742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/0db21055/attachment.bin>
More information about the llvm-commits
mailing list