Skip to content

Commit 38a6d39

Browse files
committed
[AArch64][GlobalISel] Legalize G_STORE for v4s8 Vector Type
1 parent 3eef7a5 commit 38a6d39

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

Lines changed: 16 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,10 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
422423
.clampMaxNumElements(0, s64, 2)
423424
.clampMaxNumElements(0, p0, 2)
424425
.lowerIfMemSizeNotPow2()
426+
// TODO: Use BITCAST for v2i8, v2i16
427+
.customIf(typeInSet(0, {v4s8}))
425428
.customIf(IsPtrVecPred)
426-
.scalarizeIf(typeIs(0, v2s16), 0);
429+
.scalarizeIf(typeInSet(0, {v2s16, v2s8}), 0);
427430

428431
getActionDefinitionsBuilder(G_INDEXED_STORE)
429432
// Idx 0 == Ptr, Idx 1 == Val
@@ -1599,6 +1602,18 @@ bool AArch64LegalizerInfo::legalizeLoadStore(
15991602
Register ValReg = MI.getOperand(0).getReg();
16001603
const LLT ValTy = MRI.getType(ValReg);
16011604

1605+
// G_STORE v4s8, ptr => s32 = G_BITCAST v4s8
1606+
// G_STORE s32, ptr
1607+
if (ValTy.isVector() && ValTy.getNumElements() == 4 &&
1608+
ValTy.getScalarSizeInBits() == 8) {
1609+
Register MidReg =
1610+
MIRBuilder.buildBitcast(LLT::scalar(ValTy.getSizeInBits()), ValReg)
1611+
.getReg(0);
1612+
MI.getOperand(0).setReg(MidReg);
1613+
if (!ValTy.isPointerVector() || ValTy.getAddressSpace() != 0)
1614+
return true;
1615+
}
1616+
16021617
if (ValTy == LLT::scalar(128)) {
16031618

16041619
AtomicOrdering Ordering = (*MI.memoperands_begin())->getSuccessOrdering();

llvm/test/CodeGen/AArch64/store.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
33
; RUN: llc -mtriple=aarch64 -global-isel -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
44

5-
; CHECK-GI: warning: Instruction selection used fallback path for store_v4i8
6-
75
; ===== Legal Scalars =====
86
define void @store_i8(i8 %a, ptr %ptr){
97
; CHECK-LABEL: store_i8:

0 commit comments

Comments
 (0)