1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner %s -o - | FileCheck %s
4 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(0,1,2,3))
5 # into concat_vector(Src1, Src2).
7 name: shuffle_vector_to_concat_vector_0123
8 tracksRegLiveness: true
13 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_0123
14 ; CHECK: liveins: $d0, $d1
15 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
16 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
17 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s32>) = G_CONCAT_VECTORS [[COPY]](<2 x s32>), [[COPY1]](<2 x s32>)
18 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<4 x s32>)
19 %0:_(<2 x s32>) = COPY $d0
20 %1:_(<2 x s32>) = COPY $d1
21 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(0, 1, 2, 3)
22 RET_ReallyLR implicit %2
24 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(2,3,0,1,2,3))
25 # into concat_vector(Src2, Src1, Src2).
27 name: shuffle_vector_to_concat_vector_230123
28 tracksRegLiveness: true
33 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_230123
34 ; CHECK: liveins: $d0, $d1
35 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
36 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
37 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<6 x s32>) = G_CONCAT_VECTORS [[COPY1]](<2 x s32>), [[COPY]](<2 x s32>), [[COPY1]](<2 x s32>)
38 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<6 x s32>)
39 %0:_(<2 x s32>) = COPY $d0
40 %1:_(<2 x s32>) = COPY $d1
41 %2:_(<6 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(2,3,0,1,2,3)
42 RET_ReallyLR implicit %2
44 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(2,undef,0,1,undef,3))
45 # into concat_vector(Src2, Src1, Src2).
47 name: shuffle_vector_to_concat_vector_2undef01undef3
48 tracksRegLiveness: true
53 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_2undef01undef3
54 ; CHECK: liveins: $d0, $d1
55 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
56 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
57 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<6 x s32>) = G_CONCAT_VECTORS [[COPY1]](<2 x s32>), [[COPY]](<2 x s32>), [[COPY1]](<2 x s32>)
58 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<6 x s32>)
59 %0:_(<2 x s32>) = COPY $d0
60 %1:_(<2 x s32>) = COPY $d1
61 %2:_(<6 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(2,-1,0,1,-1,3)
62 RET_ReallyLR implicit %2
64 # Check that we don't canonicalize shuffle_vector into concat_vectors
65 # when the sources get half mixed.
67 name: shuffle_vector_to_concat_vector_mixed_src_200123_neg
68 tracksRegLiveness: true
73 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_mixed_src_200123_neg
74 ; CHECK: liveins: $d0, $d1
75 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
76 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
77 ; CHECK: [[SHUF:%[0-9]+]]:_(<6 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[COPY1]], shufflemask(2, 0, 0, 1, 2, 3)
78 ; CHECK: RET_ReallyLR implicit [[SHUF]](<6 x s32>)
79 %0:_(<2 x s32>) = COPY $d0
80 %1:_(<2 x s32>) = COPY $d1
81 %2:_(<6 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(2,0,0,1,2,3)
82 RET_ReallyLR implicit %2
84 # Check that we produce implicit_def while canonicalizing shuffle_vector(Src1, Src2, mask(2,undef,undef,undef,undef,1))
85 # into concat_vector(Src2, undef, Src1).
87 name: shuffle_vector_to_concat_vector_2undef1
88 tracksRegLiveness: true
93 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_2undef1
94 ; CHECK: liveins: $d0, $d1
95 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
96 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
97 ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF
98 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<6 x s32>) = G_CONCAT_VECTORS [[COPY1]](<2 x s32>), [[DEF]](<2 x s32>), [[COPY]](<2 x s32>)
99 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<6 x s32>)
100 %0:_(<2 x s32>) = COPY $d0
101 %1:_(<2 x s32>) = COPY $d1
102 %2:_(<6 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(2,-1,-1,-1,-1,1)
103 RET_ReallyLR implicit %2
105 # Check that we don't canonicalize shuffle_vector into concat_vectors
106 # if a source is flipped.
108 name: shuffle_vector_to_concat_vector_src_flipped_230132_neg
109 tracksRegLiveness: true
114 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_src_flipped_230132_neg
115 ; CHECK: liveins: $d0, $d1
116 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
117 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
118 ; CHECK: [[SHUF:%[0-9]+]]:_(<6 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[COPY1]], shufflemask(2, 3, 0, 1, 3, 2)
119 ; CHECK: RET_ReallyLR implicit [[SHUF]](<6 x s32>)
120 %0:_(<2 x s32>) = COPY $d0
121 %1:_(<2 x s32>) = COPY $d1
122 %2:_(<6 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(2,3,0,1,3,2)
123 RET_ReallyLR implicit %2
125 # Check that we don't canonicalize shuffle_vector into concat_vectors
126 # if a source is flipped and the other half is undef.
128 name: shuffle_vector_to_concat_vector_src_flipped_23013undef_neg
129 tracksRegLiveness: true
134 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_src_flipped_23013undef_neg
135 ; CHECK: liveins: $d0, $d1
136 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
137 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
138 ; CHECK: [[SHUF:%[0-9]+]]:_(<6 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[COPY1]], shufflemask(2, 3, 0, 1, 3, -1)
139 ; CHECK: RET_ReallyLR implicit [[SHUF]](<6 x s32>)
140 %0:_(<2 x s32>) = COPY $d0
141 %1:_(<2 x s32>) = COPY $d1
142 %2:_(<6 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(2,3,0,1,3,-1)
143 RET_ReallyLR implicit %2
146 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(0,1,2,3,4,5,6,7))
147 # into concat_vector(Src1, Src2) with bigger vector type.
149 name: shuffle_vector_to_concat_vector_01234567
150 tracksRegLiveness: true
155 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_01234567
156 ; CHECK: liveins: $q0, $q1
157 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
158 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
159 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<8 x s32>) = G_CONCAT_VECTORS [[COPY]](<4 x s32>), [[COPY1]](<4 x s32>)
160 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<8 x s32>)
161 %0:_(<4 x s32>) = COPY $q0
162 %1:_(<4 x s32>) = COPY $q1
163 %2:_(<8 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(0, 1, 2, 3, 4, 5, 6, 7)
164 RET_ReallyLR implicit %2
166 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(4,5,6,7,0,1,2,3))
167 # into concat_vector(Src2, Src1, Src2) with bigger vector type.
169 name: shuffle_vector_to_concat_vector_45670123
170 tracksRegLiveness: true
175 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_45670123
176 ; CHECK: liveins: $q0, $q1
177 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
178 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
179 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<12 x s32>) = G_CONCAT_VECTORS [[COPY1]](<4 x s32>), [[COPY]](<4 x s32>), [[COPY1]](<4 x s32>)
180 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<12 x s32>)
181 %0:_(<4 x s32>) = COPY $q0
182 %1:_(<4 x s32>) = COPY $q1
183 %2:_(<12 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(4,5,6,7,0,1,2,3,4,5,6,7)
184 RET_ReallyLR implicit %2
186 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(4,5,undef,undef,0,1,2,3,undef,undef,6,7))
187 # into concat_vector(Src2, Src1, Src2) with bigger vector type.
189 name: shuffle_vector_to_concat_vector_45undefundef0123undefundef67
190 tracksRegLiveness: true
195 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_45undefundef0123undefundef67
196 ; CHECK: liveins: $q0, $q1
197 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
198 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
199 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<12 x s32>) = G_CONCAT_VECTORS [[COPY1]](<4 x s32>), [[COPY]](<4 x s32>), [[COPY1]](<4 x s32>)
200 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<12 x s32>)
201 %0:_(<4 x s32>) = COPY $q0
202 %1:_(<4 x s32>) = COPY $q1
203 %2:_(<12 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(4,5,-1,-1,0,1,2,3,-1,-1,6,7)
204 RET_ReallyLR implicit %2
206 # Check that we don't canonicalize shuffle_vector into concat_vectors
207 # when the sources get half mixed with bigger vector type.
209 name: shuffle_vector_to_concat_vector_mixed_src_456000123_neg
210 tracksRegLiveness: true
215 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_mixed_src_456000123_neg
216 ; CHECK: liveins: $q0, $q1
217 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
218 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
219 ; CHECK: [[SHUF:%[0-9]+]]:_(<8 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<4 x s32>), [[COPY1]], shufflemask(4, 5, 6, 0, 0, 1, 2, 3)
220 ; CHECK: RET_ReallyLR implicit [[SHUF]](<8 x s32>)
221 %0:_(<4 x s32>) = COPY $q0
222 %1:_(<4 x s32>) = COPY $q1
223 %2:_(<8 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(4,5,6,0,0,1,2,3)
224 RET_ReallyLR implicit %2
226 # Check that we produce implicit_def while canonicalizing shuffle_vector(Src1, Src2, mask(2,undef,undef,undef,undef,1))
227 # into concat_vector(Src2, undef, Src1) with bigger vector type.
229 name: shuffle_vector_to_concat_vector_45undefundefundefundefundefundefundefundef23
230 tracksRegLiveness: true
235 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_45undefundefundefundefundefundefundefundef23
236 ; CHECK: liveins: $q0, $q1
237 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
238 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
239 ; CHECK: [[DEF:%[0-9]+]]:_(<4 x s32>) = G_IMPLICIT_DEF
240 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<12 x s32>) = G_CONCAT_VECTORS [[COPY1]](<4 x s32>), [[DEF]](<4 x s32>), [[COPY]](<4 x s32>)
241 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<12 x s32>)
242 %0:_(<4 x s32>) = COPY $q0
243 %1:_(<4 x s32>) = COPY $q1
244 %2:_(<12 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(4,5,-1,-1,-1,-1,-1,-1,-1,-1,2,3)
245 RET_ReallyLR implicit %2
247 # Check that we don't canonicalize shuffle_vector into concat_vectors
248 # when we grab less than the full vectors.
250 name: shuffle_vector_to_concat_vector_4501_neg
251 tracksRegLiveness: true
256 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_4501_neg
257 ; CHECK: liveins: $q0, $q1
258 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
259 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
260 ; CHECK: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<4 x s32>), [[COPY1]], shufflemask(4, 5, 0, 1)
261 ; CHECK: RET_ReallyLR implicit [[SHUF]](<4 x s32>)
262 %0:_(<4 x s32>) = COPY $q0
263 %1:_(<4 x s32>) = COPY $q1
264 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(4,5,0,1)
265 RET_ReallyLR implicit %2
267 # Check that we don't canonicalize shuffle_vector into concat_vectors
268 # if a source is flipped and the other half is undef with bigger vector.
270 name: shuffle_vector_to_concat_vector_src_flipped_4567012367undefundef_neg
271 tracksRegLiveness: true
276 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_src_flipped_4567012367undefundef_neg
277 ; CHECK: liveins: $q0, $q1
278 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
279 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
280 ; CHECK: [[SHUF:%[0-9]+]]:_(<12 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<4 x s32>), [[COPY1]], shufflemask(4, 5, 6, 7, 0, 1, 2, 3, 6, 7, -1, -1)
281 ; CHECK: RET_ReallyLR implicit [[SHUF]](<12 x s32>)
282 %0:_(<4 x s32>) = COPY $q0
283 %1:_(<4 x s32>) = COPY $q1
284 %2:_(<12 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1(<4 x s32>), shufflemask(4,5,6,7,0,1,2,3,6,7,-1,-1)
285 RET_ReallyLR implicit %2
287 # Check that we canonicalize shuffle_vector(Src1, Src2, mask(4,5,undef,undef,0,1,2,3,undef,undef,6,7))
288 # into concat_vector(Src2, Src1, Src2) with vector of pointers.
290 name: shuffle_vector_to_concat_vector_45undefundef0123undefundef67_ptr
291 tracksRegLiveness: true
294 liveins: $q0_q1, $q2_q3
296 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_45undefundef0123undefundef67_ptr
297 ; CHECK: liveins: $q0_q1, $q2_q3
298 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x p0>) = COPY $q0_q1
299 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x p0>) = COPY $q2_q3
300 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<12 x p0>) = G_CONCAT_VECTORS [[COPY1]](<4 x p0>), [[COPY]](<4 x p0>), [[COPY1]](<4 x p0>)
301 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<12 x p0>)
302 %0:_(<4 x p0>) = COPY $q0_q1
303 %1:_(<4 x p0>) = COPY $q2_q3
304 %2:_(<12 x p0>) = G_SHUFFLE_VECTOR %0(<4 x p0>), %1(<4 x p0>), shufflemask(4,5,-1,-1,0,1,2,3,-1,-1,6,7)
305 RET_ReallyLR implicit %2
307 # Check that we don't canonicalize shuffle_vector into concat_vectors
308 # when the sources get half mixed with vector of pointers.
310 name: shuffle_vector_to_concat_vector_mixed_src_456000123_neg_ptr
311 tracksRegLiveness: true
314 liveins: $q0_q1, $q2_q3
316 ; CHECK-LABEL: name: shuffle_vector_to_concat_vector_mixed_src_456000123_neg_ptr
317 ; CHECK: liveins: $q0_q1, $q2_q3
318 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x p0>) = COPY $q0_q1
319 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x p0>) = COPY $q2_q3
320 ; CHECK: [[SHUF:%[0-9]+]]:_(<8 x p0>) = G_SHUFFLE_VECTOR [[COPY]](<4 x p0>), [[COPY1]], shufflemask(4, 5, 6, 0, 0, 1, 2, 3)
321 ; CHECK: RET_ReallyLR implicit [[SHUF]](<8 x p0>)
322 %0:_(<4 x p0>) = COPY $q0_q1
323 %1:_(<4 x p0>) = COPY $q2_q3
324 %2:_(<8 x p0>) = G_SHUFFLE_VECTOR %0(<4 x p0>), %1(<4 x p0>), shufflemask(4,5,6,0,0,1,2,3)
325 RET_ReallyLR implicit %2
328 # Check that shuffle_vector gets combined into concat_vectors then the
329 # concat_vectors gets combined into build_vector.
331 name: shuffle_vector_to_build_vector_ptr
332 tracksRegLiveness: true
335 liveins: $x0, $x1, $x2, $x3
337 ; CHECK-LABEL: name: shuffle_vector_to_build_vector_ptr
338 ; CHECK: liveins: $x0, $x1, $x2, $x3
339 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
340 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
341 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY $x2
342 ; CHECK: [[COPY3:%[0-9]+]]:_(p0) = COPY $x3
343 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x p0>) = G_BUILD_VECTOR [[COPY]](p0), [[COPY1]](p0), [[COPY2]](p0), [[COPY3]](p0)
344 ; CHECK: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x p0>)
349 %4:_(<2 x p0>) = G_BUILD_VECTOR %0(p0), %1
350 %5:_(<2 x p0>) = G_BUILD_VECTOR %2(p0), %3
351 %6:_(<4 x p0>) = G_SHUFFLE_VECTOR %4(<2 x p0>), %5(<2 x p0>), shufflemask(0,1,2,3)
352 RET_ReallyLR implicit %6