Skip to content

[AArch64][GlobalISel] Legalize G_LOAD for v4s8 Vector #82989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,14 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
.clampMaxNumElements(0, s32, 4)
.clampMaxNumElements(0, s64, 2)
.clampMaxNumElements(0, p0, 2)
// TODO: Use BITCAST for v2i8, v2i16 after G_TRUNC gets sorted out
.bitcastIf(typeInSet(0, {v4s8}),
[=](const LegalityQuery &Query) {
const LLT VecTy = Query.Types[0];
return std::pair(0, LLT::scalar(VecTy.getSizeInBits()));
})
.customIf(IsPtrVecPred)
.scalarizeIf(typeIs(0, v2s16), 0);
.scalarizeIf(typeInSet(0, {v2s16, v2s8}), 0);

getActionDefinitionsBuilder(G_STORE)
.customIf([=](const LegalityQuery &Query) {
Expand Down
27 changes: 16 additions & 11 deletions llvm/test/CodeGen/AArch64/load.ll
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI

; CHECK-GI: warning: Instruction selection used fallback path for load_v2i8
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for load_v4i8
; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI

; ===== Legal Scalars =====

Expand Down Expand Up @@ -111,13 +108,21 @@ define <2 x i64> @load_v2i64(ptr %ptr){
; ===== Smaller/Larger Width Vectors with Legal Element Sizes =====

define <2 x i8> @load_v2i8(ptr %ptr, <2 x i8> %b){
; CHECK-LABEL: load_v2i8:
; CHECK: // %bb.0:
; CHECK-NEXT: ld1 { v0.b }[0], [x0]
; CHECK-NEXT: add x8, x0, #1
; CHECK-NEXT: ld1 { v0.b }[4], [x8]
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-NEXT: ret
; CHECK-SD-LABEL: load_v2i8:
; CHECK-SD: // %bb.0:
; CHECK-SD-NEXT: ld1 { v0.b }[0], [x0]
; CHECK-SD-NEXT: add x8, x0, #1
; CHECK-SD-NEXT: ld1 { v0.b }[4], [x8]
; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-SD-NEXT: ret
;
; CHECK-GI-LABEL: load_v2i8:
; CHECK-GI: // %bb.0:
; CHECK-GI-NEXT: ldr b0, [x0]
; CHECK-GI-NEXT: ldr b1, [x0, #1]
; CHECK-GI-NEXT: mov v0.s[1], v1.s[0]
; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-GI-NEXT: ret
%a = load <2 x i8>, ptr %ptr
ret <2 x i8> %a
}
Expand Down