Skip to content

Commit 4594d5b

Browse files
authored
[AArch64] Add missing bf16 store pattern (#72844)
We have STURHi store patterns but would fail to select from unscaled offsets. This adds the missing pattern.
1 parent 5d35342 commit 4594d5b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,6 +3926,11 @@ defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
39263926
[(truncstorei8 GPR32z:$Rt,
39273927
(am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
39283928

3929+
// bf16 store pattern
3930+
def : Pat<(store (bf16 FPR16Op:$Rt),
3931+
(am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
3932+
(STURHi FPR16:$Rt, GPR64sp:$Rn, simm9:$offset)>;
3933+
39293934
// Armv8.4 Weaker Release Consistency enhancements
39303935
// LDAPR & STLR with Immediate Offset instructions
39313936
let Predicates = [HasRCPC_IMMO] in {

llvm/test/CodeGen/AArch64/bf16.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ define void @test_store(ptr %a, bfloat %b) nounwind {
4545
ret void
4646
}
4747

48+
define void @test_store_negative_offset(ptr %a, bfloat %b) nounwind {
49+
; CHECK-LABEL: test_store_negative_offset:
50+
; CHECK-NEXT: stur h0, [x0, #-4]
51+
; CHECK-NEXT: ret
52+
entry:
53+
%0 = getelementptr inbounds bfloat, ptr %a, i64 -2
54+
store bfloat %b, ptr %0, align 2
55+
ret void
56+
}
57+
4858
; Simple store of v4bf16
4959
define void @test_vec_store(ptr %a, <4 x bfloat> %b) nounwind {
5060
; CHECK-LABEL: test_vec_store:

0 commit comments

Comments
 (0)