1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
3 # Check that we can recognize a shuffle mask for a zip instruction, and produce
4 # G_ZIP1 or G_ZIP2 where appropriate.
6 # RUN: llc -mtriple aarch64 -run-pass=aarch64-postlegalizer-lowering -verify-machineinstrs %s -o - | FileCheck %s
13 tracksRegLiveness: true
18 ; CHECK-LABEL: name: zip1_v2s32
19 ; CHECK: liveins: $d0, $d1
21 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
22 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
23 ; CHECK-NEXT: [[ZIP1_:%[0-9]+]]:_(<2 x s32>) = G_ZIP1 [[COPY]], [[COPY1]]
24 ; CHECK-NEXT: $d0 = COPY [[ZIP1_]](<2 x s32>)
25 ; CHECK-NEXT: RET_ReallyLR implicit $d0
26 %0:_(<2 x s32>) = COPY $d0
27 %1:_(<2 x s32>) = COPY $d1
28 %2:_(<2 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1, shufflemask(0, 2)
29 $d0 = COPY %2(<2 x s32>)
30 RET_ReallyLR implicit $d0
37 tracksRegLiveness: true
42 ; CHECK-LABEL: name: zip1_v2s64
43 ; CHECK: liveins: $q0, $q1
45 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
46 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
47 ; CHECK-NEXT: [[ZIP1_:%[0-9]+]]:_(<2 x s64>) = G_ZIP1 [[COPY]], [[COPY1]]
48 ; CHECK-NEXT: $q0 = COPY [[ZIP1_]](<2 x s64>)
49 ; CHECK-NEXT: RET_ReallyLR implicit $q0
50 %0:_(<2 x s64>) = COPY $q0
51 %1:_(<2 x s64>) = COPY $q1
52 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(0, 2)
53 $q0 = COPY %2(<2 x s64>)
54 RET_ReallyLR implicit $q0
61 tracksRegLiveness: true
66 ; CHECK-LABEL: name: zip1_v4s32
67 ; CHECK: liveins: $q0, $q1
69 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
70 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
71 ; CHECK-NEXT: [[ZIP1_:%[0-9]+]]:_(<4 x s32>) = G_ZIP1 [[COPY]], [[COPY1]]
72 ; CHECK-NEXT: $q0 = COPY [[ZIP1_]](<4 x s32>)
73 ; CHECK-NEXT: RET_ReallyLR implicit $q0
74 %0:_(<4 x s32>) = COPY $q0
75 %1:_(<4 x s32>) = COPY $q1
76 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(0, 4, 1, 5)
77 $q0 = COPY %2(<4 x s32>)
78 RET_ReallyLR implicit $q0
85 tracksRegLiveness: true
90 ; CHECK-LABEL: name: zip2_v2s32
91 ; CHECK: liveins: $d0, $d1
93 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
94 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
95 ; CHECK-NEXT: [[ZIP2_:%[0-9]+]]:_(<2 x s32>) = G_ZIP2 [[COPY]], [[COPY1]]
96 ; CHECK-NEXT: $d0 = COPY [[ZIP2_]](<2 x s32>)
97 ; CHECK-NEXT: RET_ReallyLR implicit $d0
98 %0:_(<2 x s32>) = COPY $d0
99 %1:_(<2 x s32>) = COPY $d1
100 %2:_(<2 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1, shufflemask(1, 3)
101 $d0 = COPY %2(<2 x s32>)
102 RET_ReallyLR implicit $d0
109 tracksRegLiveness: true
114 ; CHECK-LABEL: name: zip2_v2s64
115 ; CHECK: liveins: $q0, $q1
117 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
118 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
119 ; CHECK-NEXT: [[ZIP2_:%[0-9]+]]:_(<2 x s64>) = G_ZIP2 [[COPY]], [[COPY1]]
120 ; CHECK-NEXT: $q0 = COPY [[ZIP2_]](<2 x s64>)
121 ; CHECK-NEXT: RET_ReallyLR implicit $q0
122 %0:_(<2 x s64>) = COPY $q0
123 %1:_(<2 x s64>) = COPY $q1
124 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(1, 3)
125 $q0 = COPY %2(<2 x s64>)
126 RET_ReallyLR implicit $q0
133 tracksRegLiveness: true
138 ; CHECK-LABEL: name: zip2_v4s32
139 ; CHECK: liveins: $q0, $q1
141 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
142 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
143 ; CHECK-NEXT: [[ZIP2_:%[0-9]+]]:_(<4 x s32>) = G_ZIP2 [[COPY]], [[COPY1]]
144 ; CHECK-NEXT: $q0 = COPY [[ZIP2_]](<4 x s32>)
145 ; CHECK-NEXT: RET_ReallyLR implicit $q0
146 %0:_(<4 x s32>) = COPY $q0
147 %1:_(<4 x s32>) = COPY $q1
148 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(2, 6, 3, 7)
149 $q0 = COPY %2(<4 x s32>)
150 RET_ReallyLR implicit $q0
154 name: zip2_no_combine_idx_mismatch
157 tracksRegLiveness: true
162 ; This will fail because it expects 3 to be the second element of the
163 ; shuffle vector mask.
165 ; CHECK-LABEL: name: zip2_no_combine_idx_mismatch
166 ; CHECK: liveins: $q0, $q1
168 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
169 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
170 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
171 ; CHECK-NEXT: [[EXT:%[0-9]+]]:_(<2 x s64>) = G_EXT [[COPY]], [[COPY1]], [[C]](s32)
172 ; CHECK-NEXT: $q0 = COPY [[EXT]](<2 x s64>)
173 ; CHECK-NEXT: RET_ReallyLR implicit $q0
174 %0:_(<2 x s64>) = COPY $q0
175 %1:_(<2 x s64>) = COPY $q1
176 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(1, 2)
177 $q0 = COPY %2(<2 x s64>)
178 RET_ReallyLR implicit $q0
182 name: zip1_no_combine_idx_mismatch
185 tracksRegLiveness: true
190 ; This will fail because it expects 2 to be the second element of the
191 ; shuffle vector mask.
193 ; CHECK-LABEL: name: zip1_no_combine_idx_mismatch
194 ; CHECK: liveins: $q0, $q1
196 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
197 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY [[COPY]](<2 x s64>)
198 ; CHECK-NEXT: $q0 = COPY [[COPY1]](<2 x s64>)
199 ; CHECK-NEXT: RET_ReallyLR implicit $q0
200 %0:_(<2 x s64>) = COPY $q0
201 %1:_(<2 x s64>) = COPY $q1
202 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(0, 1)
203 $q0 = COPY %2(<2 x s64>)
204 RET_ReallyLR implicit $q0
208 name: no_combine_first_elt_of_mask_must_be_zero_or_one
211 tracksRegLiveness: true
216 ; zip1/zip2 must have 0 or 1 as the first element in the shuffle mask.
218 ; CHECK-LABEL: name: no_combine_first_elt_of_mask_must_be_zero_or_one
219 ; CHECK: liveins: $q0, $q1
221 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
222 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
223 ; CHECK-NEXT: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<4 x s32>), [[COPY1]], shufflemask(3, 4, 1, 5)
224 ; CHECK-NEXT: $q0 = COPY [[SHUF]](<4 x s32>)
225 ; CHECK-NEXT: RET_ReallyLR implicit $q0
226 %0:_(<4 x s32>) = COPY $q0
227 %1:_(<4 x s32>) = COPY $q1
228 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(3, 4, 1, 5)
229 $q0 = COPY %2(<4 x s32>)
230 RET_ReallyLR implicit $q0