Skip to content

Commit f3f3098

Browse files
author
Jessica Paquette
committed
[AArch64][GlobalISel] Mark v16s8 <- v8s8, v8s8 G_CONCAT_VECTOR as legal
G_CONCAT_VECTORS shows up from time to time when legalizing other instructions. We actually import patterns for the v16s8 <- v8s8, v8s8 case so marking it as legal gives us selection for free. Differential Revision: https://reviews.llvm.org/D107512
1 parent 180f4a8 commit f3f3098

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
723723
.clampNumElements(0, v2s64, v2s64);
724724

725725
getActionDefinitionsBuilder(G_CONCAT_VECTORS)
726-
.legalFor({{v4s32, v2s32}, {v8s16, v4s16}});
726+
.legalFor({{v4s32, v2s32}, {v8s16, v4s16}, {v16s8, v8s8}});
727727

728728
getActionDefinitionsBuilder(G_JUMP_TABLE).legalFor({{p0}, {s64}});
729729

llvm/test/CodeGen/AArch64/GlobalISel/legalize-concat-vectors.mir

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -mtriple=aarch64-linux-gnu -O0 -run-pass=legalizer %s -global-isel-abort=1 -o - | FileCheck %s
2+
# RUN: llc -mtriple=aarch64-linux-gnu -O0 -run-pass=legalizer %s -global-isel-abort=1 -verify-machineinstrs -o - | FileCheck %s
33

44
---
55
name: legal_v4s32_v2s32
6+
tracksRegLiveness: true
67
body: |
78
bb.0:
89
liveins: $d0, $d1
910
; CHECK-LABEL: name: legal_v4s32_v2s32
11+
; CHECK: liveins: $d0, $d1
1012
; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
1113
; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
1214
; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s32>) = G_CONCAT_VECTORS [[COPY]](<2 x s32>), [[COPY1]](<2 x s32>)
@@ -20,10 +22,12 @@ body: |
2022
...
2123
---
2224
name: legal_v8s16_v4s16
25+
tracksRegLiveness: true
2326
body: |
2427
bb.0:
2528
liveins: $d0, $d1
2629
; CHECK-LABEL: name: legal_v8s16_v4s16
30+
; CHECK: liveins: $d0, $d1
2731
; CHECK: [[COPY:%[0-9]+]]:_(<4 x s16>) = COPY $d0
2832
; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s16>) = COPY $d1
2933
; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<8 x s16>) = G_CONCAT_VECTORS [[COPY]](<4 x s16>), [[COPY1]](<4 x s16>)
@@ -35,3 +39,22 @@ body: |
3539
$q0 = COPY %2(<8 x s16>)
3640
RET_ReallyLR
3741
...
42+
---
43+
name: legal_v16s8_v8s8
44+
tracksRegLiveness: true
45+
body: |
46+
bb.0:
47+
liveins: $q0
48+
; CHECK-LABEL: name: legal_v16s8_v8s8
49+
; CHECK: liveins: $q0
50+
; CHECK: %a:_(<8 x s8>) = G_IMPLICIT_DEF
51+
; CHECK: %b:_(<8 x s8>) = G_IMPLICIT_DEF
52+
; CHECK: %concat:_(<16 x s8>) = G_CONCAT_VECTORS %a(<8 x s8>), %b(<8 x s8>)
53+
; CHECK: $q0 = COPY %concat(<16 x s8>)
54+
; CHECK: RET_ReallyLR implicit $q0
55+
%a:_(<8 x s8>) = G_IMPLICIT_DEF
56+
%b:_(<8 x s8>) = G_IMPLICIT_DEF
57+
%concat:_(<16 x s8>) = G_CONCAT_VECTORS %a:_(<8 x s8>), %b:_(<8 x s8>)
58+
$q0 = COPY %concat(<16 x s8>)
59+
RET_ReallyLR implicit $q0
60+
...

llvm/test/CodeGen/AArch64/GlobalISel/select-concat-vectors.mir

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,52 @@ body: |
6767
RET_ReallyLR implicit $q0
6868
6969
...
70+
---
71+
name: select_v16s8_v8s8_undef
72+
legalized: true
73+
regBankSelected: true
74+
tracksRegLiveness: true
75+
body: |
76+
bb.0:
77+
liveins: $q0
78+
79+
; CHECK-LABEL: name: select_v16s8_v8s8_undef
80+
; CHECK: liveins: $q0
81+
; CHECK: %a:fpr64 = IMPLICIT_DEF
82+
; CHECK: [[DEF:%[0-9]+]]:fpr128 = IMPLICIT_DEF
83+
; CHECK: %concat:fpr128 = INSERT_SUBREG [[DEF]], %a, %subreg.dsub
84+
; CHECK: $q0 = COPY %concat
85+
; CHECK: RET_ReallyLR implicit $q0
86+
%a:fpr(<8 x s8>) = G_IMPLICIT_DEF
87+
%b:fpr(<8 x s8>) = G_IMPLICIT_DEF
88+
%concat:fpr(<16 x s8>) = G_CONCAT_VECTORS %a(<8 x s8>), %b(<8 x s8>)
89+
$q0 = COPY %concat(<16 x s8>)
90+
RET_ReallyLR implicit $q0
91+
92+
...
93+
---
94+
name: select_v16s8_v8s8_not_undef
95+
legalized: true
96+
regBankSelected: true
97+
tracksRegLiveness: true
98+
body: |
99+
bb.0:
100+
liveins: $q0, $d1
101+
; CHECK-LABEL: name: select_v16s8_v8s8_not_undef
102+
; CHECK: liveins: $q0, $d1
103+
; CHECK: %a:fpr64 = COPY $d0
104+
; CHECK: %b:fpr64 = COPY $d1
105+
; CHECK: [[DEF:%[0-9]+]]:fpr128 = IMPLICIT_DEF
106+
; CHECK: [[INSERT_SUBREG:%[0-9]+]]:fpr128 = INSERT_SUBREG [[DEF]], %b, %subreg.dsub
107+
; CHECK: [[DEF1:%[0-9]+]]:fpr128 = IMPLICIT_DEF
108+
; CHECK: [[INSERT_SUBREG1:%[0-9]+]]:fpr128 = INSERT_SUBREG [[DEF1]], %a, %subreg.dsub
109+
; CHECK: %concat:fpr128 = INSvi64lane [[INSERT_SUBREG1]], 1, [[INSERT_SUBREG]], 0
110+
; CHECK: $q0 = COPY %concat
111+
; CHECK: RET_ReallyLR implicit $q0
112+
%a:fpr(<8 x s8>) = COPY $d0
113+
%b:fpr(<8 x s8>) = COPY $d1
114+
%concat:fpr(<16 x s8>) = G_CONCAT_VECTORS %a(<8 x s8>), %b(<8 x s8>)
115+
$q0 = COPY %concat(<16 x s8>)
116+
RET_ReallyLR implicit $q0
117+
118+
...

0 commit comments

Comments
 (0)