Skip to content

Commit 420b339

Browse files
committed
[AArch64][GlobalISel] Legalize G_STORE for v4s8 Vector Type
1 parent 5468f88 commit 420b339

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
5252
const LLT v16s8 = LLT::fixed_vector(16, 8);
5353
const LLT v8s8 = LLT::fixed_vector(8, 8);
5454
const LLT v4s8 = LLT::fixed_vector(4, 8);
55+
const LLT v2s8 = LLT::fixed_vector(2, 8);
5556
const LLT v8s16 = LLT::fixed_vector(8, 16);
5657
const LLT v4s16 = LLT::fixed_vector(4, 16);
5758
const LLT v2s16 = LLT::fixed_vector(2, 16);
@@ -422,8 +423,14 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
422423
.clampMaxNumElements(0, s64, 2)
423424
.clampMaxNumElements(0, p0, 2)
424425
.lowerIfMemSizeNotPow2()
426+
// TODO: Use BITCAST for v2i8, v2i16 after G_TRUNC gets sorted out
427+
.bitcastIf(typeInSet(0, {v4s8}),
428+
[=](const LegalityQuery &Query) {
429+
const LLT VecTy = Query.Types[0];
430+
return std::pair(0, LLT::scalar(VecTy.getSizeInBits()));
431+
})
425432
.customIf(IsPtrVecPred)
426-
.scalarizeIf(typeIs(0, v2s16), 0);
433+
.scalarizeIf(typeInSet(0, {v2s16, v2s8}), 0);
427434

428435
getActionDefinitionsBuilder(G_INDEXED_STORE)
429436
// Idx 0 == Ptr, Idx 1 == Val

llvm/test/CodeGen/AArch64/store.ll

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
22
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3-
; RUN: llc -mtriple=aarch64 -global-isel -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
4-
5-
; CHECK-GI: warning: Instruction selection used fallback path for store_v2i8
6-
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for store_v4i8
3+
; RUN: llc -mtriple=aarch64 -global-isel %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
74

85
; ===== Legal Scalars =====
96
define void @store_i8(i8 %a, ptr %ptr){
@@ -110,14 +107,22 @@ define void @store_v2i64(<2 x i64> %a, ptr %ptr){
110107
; ===== Smaller/Larger Width Vectors with Legal Element Sizes =====
111108

112109
define void @store_v2i8(<2 x i8> %a, ptr %ptr){
113-
; CHECK-LABEL: store_v2i8:
114-
; CHECK: // %bb.0:
115-
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
116-
; CHECK-NEXT: mov w8, v0.s[1]
117-
; CHECK-NEXT: fmov w9, s0
118-
; CHECK-NEXT: strb w9, [x0]
119-
; CHECK-NEXT: strb w8, [x0, #1]
120-
; CHECK-NEXT: ret
110+
; CHECK-SD-LABEL: store_v2i8:
111+
; CHECK-SD: // %bb.0:
112+
; CHECK-SD-NEXT: // kill: def $d0 killed $d0 def $q0
113+
; CHECK-SD-NEXT: mov w8, v0.s[1]
114+
; CHECK-SD-NEXT: fmov w9, s0
115+
; CHECK-SD-NEXT: strb w9, [x0]
116+
; CHECK-SD-NEXT: strb w8, [x0, #1]
117+
; CHECK-SD-NEXT: ret
118+
;
119+
; CHECK-GI-LABEL: store_v2i8:
120+
; CHECK-GI: // %bb.0:
121+
; CHECK-GI-NEXT: // kill: def $d0 killed $d0 def $q0
122+
; CHECK-GI-NEXT: mov s1, v0.s[1]
123+
; CHECK-GI-NEXT: str b0, [x0]
124+
; CHECK-GI-NEXT: str b1, [x0, #1]
125+
; CHECK-GI-NEXT: ret
121126
store <2 x i8> %a, ptr %ptr
122127
ret void
123128
}

0 commit comments

Comments
 (0)