[llvm] ae12e57 - [AArch64] Add missing bf16 load insert pattern
David Green via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 3 14:00:46 PST 2023
Author: David Green
Date: 2023-03-03T22:00:41Z
New Revision: ae12e57a777f2287a656e17a6ce86ca6b86edb6e
URL: https://github.com/llvm/llvm-project/commit/ae12e57a777f2287a656e17a6ce86ca6b86edb6e
DIFF: https://github.com/llvm/llvm-project/commit/ae12e57a777f2287a656e17a6ce86ca6b86edb6e.diff
LOG: [AArch64] Add missing bf16 load insert pattern
We have LDRHui load patterns but would fail to select from unscaled offsets.
This adds the missing pattern.
Added:
Modified:
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/bf16.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index c91e7b7c64fdf..2ab27f5225ea2 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -3154,6 +3154,10 @@ defm LDURBB
[(set GPR32:$Rt,
(zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
+// bf16 load pattern
+def : Pat <(bf16 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
+ (LDURHi GPR64sp:$Rn, simm9:$offset)>;
+
// Match all load 64 bits width whose type is compatible with FPR64
let Predicates = [IsLE] in {
def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
diff --git a/llvm/test/CodeGen/AArch64/bf16.ll b/llvm/test/CodeGen/AArch64/bf16.ll
index ad05f07b9b8be..14ce317e7e383 100644
--- a/llvm/test/CodeGen/AArch64/bf16.ll
+++ b/llvm/test/CodeGen/AArch64/bf16.ll
@@ -11,6 +11,24 @@ define bfloat @test_load(ptr %p) nounwind {
ret bfloat %tmp1
}
+define bfloat @test_load_offset1(ptr %p) nounwind {
+; CHECK-LABEL: test_load_offset1:
+; CHECK-NEXT: ldur h0, [x0, #1]
+; CHECK-NEXT: ret
+ %g = getelementptr inbounds i8, ptr %p, i64 1
+ %tmp1 = load bfloat, ptr %g, align 2
+ ret bfloat %tmp1
+}
+
+define bfloat @test_load_offset2(ptr %p) nounwind {
+; CHECK-LABEL: test_load_offset2:
+; CHECK-NEXT: ldr h0, [x0, #2]
+; CHECK-NEXT: ret
+ %g = getelementptr inbounds i8, ptr %p, i64 2
+ %tmp1 = load bfloat, ptr %g, align 2
+ ret bfloat %tmp1
+}
+
define <4 x bfloat> @test_vec_load(ptr %p) nounwind {
; CHECK-LABEL: test_vec_load:
; CHECK-NEXT: ldr d0, [x0]
More information about the llvm-commits
mailing list