1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs  %s | FileCheck %s
3
4# Simple unmerge(merge) case with two operands.
5# The sources of the merge can be used in place of
6# the destinations of the unmerge.
7---
8name:            test_combine_unmerge_merge
9body:             |
10  bb.1:
11    ; CHECK-LABEL: name: test_combine_unmerge_merge
12    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
13    ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
14    ; CHECK: $w0 = COPY [[DEF]](s32)
15    ; CHECK: $w1 = COPY [[DEF1]](s32)
16    %0:_(s32) = G_IMPLICIT_DEF
17    %1:_(s32) = G_IMPLICIT_DEF
18    %2:_(s64) = G_MERGE_VALUES %0(s32), %1(s32)
19    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %2(s64)
20    $w0 = COPY %3(s32)
21    $w1 = COPY %4(s32)
22...
23
24# Simple unmerge(merge) case with three operands.
25# The sources of the merge can be used in place of
26# the destinations of the unmerge.
27---
28name:            test_combine_unmerge_merge_3ops
29body:             |
30  bb.1:
31    ; CHECK-LABEL: name: test_combine_unmerge_merge_3ops
32    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
33    ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
34    ; CHECK: [[DEF2:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
35    ; CHECK: $w0 = COPY [[DEF]](s32)
36    ; CHECK: $w1 = COPY [[DEF1]](s32)
37    ; CHECK: $w2 = COPY [[DEF2]](s32)
38    %0:_(s32) = G_IMPLICIT_DEF
39    %1:_(s32) = G_IMPLICIT_DEF
40    %5:_(s32) = G_IMPLICIT_DEF
41    %2:_(s96) = G_MERGE_VALUES %0(s32), %1(s32), %5(s32)
42    %3:_(s32), %4:_(s32), %6:_(s32) = G_UNMERGE_VALUES %2(s96)
43    $w0 = COPY %3(s32)
44    $w1 = COPY %4(s32)
45    $w2 = COPY %6(s32)
46...
47
48# Simple unmerge(buildvector) case with two operands.
49# The sources of the buildvector can be used in place of
50# the destinations of the unmerge.
51---
52name:            test_combine_unmerge_build_vector
53body:             |
54  bb.1:
55    ; CHECK-LABEL: name: test_combine_unmerge_build_vector
56    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
57    ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
58    ; CHECK: $w0 = COPY [[DEF]](s32)
59    ; CHECK: $w1 = COPY [[DEF1]](s32)
60    %0:_(s32) = G_IMPLICIT_DEF
61    %1:_(s32) = G_IMPLICIT_DEF
62    %2:_(<2 x s32>) = G_BUILD_VECTOR %0(s32), %1(s32)
63    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %2(<2 x s32>)
64    $w0 = COPY %3(s32)
65    $w1 = COPY %4(s32)
66...
67
68# Simple unmerge(buildvector) case with three operands.
69# The sources of the buildvector can be used in place of
70# the destinations of the unmerge.
71---
72name:            test_combine_unmerge_buildvector_3ops
73body:             |
74  bb.1:
75    ; CHECK-LABEL: name: test_combine_unmerge_buildvector_3ops
76    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
77    ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
78    ; CHECK: [[DEF2:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
79    ; CHECK: $w0 = COPY [[DEF]](s32)
80    ; CHECK: $w1 = COPY [[DEF1]](s32)
81    ; CHECK: $w2 = COPY [[DEF2]](s32)
82    %0:_(s32) = G_IMPLICIT_DEF
83    %1:_(s32) = G_IMPLICIT_DEF
84    %5:_(s32) = G_IMPLICIT_DEF
85    %2:_(<3 x s32>) = G_BUILD_VECTOR %0(s32), %1(s32), %5(s32)
86    %3:_(s32), %4:_(s32), %6:_(s32) = G_UNMERGE_VALUES %2(<3 x s32>)
87    $w0 = COPY %3(s32)
88    $w1 = COPY %4(s32)
89    $w2 = COPY %6(s32)
90...
91
92# Simple unmerge(concatvectors) case.
93# The sources of the concatvectors can be used in place of
94# the destinations of the unmerge.
95---
96name:            test_combine_unmerge_concat_vectors
97body:             |
98  bb.1:
99    ; CHECK-LABEL: name: test_combine_unmerge_concat_vectors
100    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $w0
101    ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s16>) = COPY $w1
102    ; CHECK: $w0 = COPY [[COPY]](<2 x s16>)
103    ; CHECK: $w1 = COPY [[COPY1]](<2 x s16>)
104    %0:_(<2 x s16>) = COPY $w0
105    %1:_(<2 x s16>) = COPY $w1
106    %2:_(<4 x s16>) = G_CONCAT_VECTORS %0(<2 x s16>), %1(<2 x s16>)
107    %3:_(<2 x s16>), %4:_(<2 x s16>) = G_UNMERGE_VALUES %2(<4 x s16>)
108    $w0 = COPY %3(<2 x s16>)
109    $w1 = COPY %4(<2 x s16>)
110...
111
112# Unmerge(merge) case with two operands and a bitcast in the middle.
113# The sources of the merge can be used in place of
114# the destinations of the unmerge.
115---
116name:            test_combine_unmerge_bitcast_merge
117body:             |
118  bb.1:
119    ; CHECK-LABEL: name: test_combine_unmerge_bitcast_merge
120    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
121    ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
122    ; CHECK: $w0 = COPY [[DEF]](s32)
123    ; CHECK: $w1 = COPY [[DEF1]](s32)
124    %0:_(s32) = G_IMPLICIT_DEF
125    %1:_(s32) = G_IMPLICIT_DEF
126    %2:_(s64) = G_MERGE_VALUES %0(s32), %1(s32)
127    %5:_(<2 x s32>) = G_BITCAST %2(s64)
128    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %5(<2 x s32>)
129    $w0 = COPY %3(s32)
130    $w1 = COPY %4(s32)
131...
132
133# Unmerge(merge) with incompatible types: unmerge destTy != merge inputTy.
134# The sources of the merge cannot be used in place of
135# the destinations of the unmerge, since the types don't match.
136---
137name:            test_combine_unmerge_merge_incompatible_types
138body:             |
139  bb.1:
140    ; CHECK-LABEL: name: test_combine_unmerge_merge_incompatible_types
141    ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
142    ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
143    ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[DEF]](s32), [[DEF1]](s32)
144    ; CHECK: [[UV:%[0-9]+]]:_(s16), [[UV1:%[0-9]+]]:_(s16), [[UV2:%[0-9]+]]:_(s16), [[UV3:%[0-9]+]]:_(s16) = G_UNMERGE_VALUES [[MV]](s64)
145    ; CHECK: $h0 = COPY [[UV]](s16)
146    ; CHECK: $h1 = COPY [[UV1]](s16)
147    ; CHECK: $h2 = COPY [[UV2]](s16)
148    ; CHECK: $h3 = COPY [[UV3]](s16)
149    %0:_(s32) = G_IMPLICIT_DEF
150    %1:_(s32) = G_IMPLICIT_DEF
151    %2:_(s64) = G_MERGE_VALUES %0(s32), %1(s32)
152    %3:_(s16), %4:_(s16), %5:_(s16), %6:_(s16) = G_UNMERGE_VALUES %2(s64)
153    $h0 = COPY %3(s16)
154    $h1 = COPY %4(s16)
155    $h2 = COPY %5(s16)
156    $h3 = COPY %6(s16)
157...
158
159# Unmerge(concatvectors) with incompatible types: unmerge destTy != merge inputTy
160# but destTy.size() == inputTy.size().
161# The sources of the concatvectors can be used in place of
162# the destinations of the unmerge with a bitcast since the sizes
163# match.
164---
165name:            test_combine_unmerge_merge_incompatible_types_but_same_size
166body:             |
167  bb.1:
168    ; CHECK-LABEL: name: test_combine_unmerge_merge_incompatible_types_but_same_size
169    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $w0
170    ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s16>) = COPY $w1
171    ; CHECK: [[BITCAST:%[0-9]+]]:_(s32) = G_BITCAST [[COPY]](<2 x s16>)
172    ; CHECK: [[BITCAST1:%[0-9]+]]:_(s32) = G_BITCAST [[COPY1]](<2 x s16>)
173    ; CHECK: $w0 = COPY [[BITCAST]](s32)
174    ; CHECK: $w1 = COPY [[BITCAST1]](s32)
175    %0:_(<2 x s16>) = COPY $w0
176    %1:_(<2 x s16>) = COPY $w1
177    %2:_(<4 x s16>) = G_CONCAT_VECTORS %0(<2 x s16>), %1(<2 x s16>)
178    %5:_(s64) = G_BITCAST %2(<4 x s16>)
179    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %5(s64)
180    $w0 = COPY %3(s32)
181    $w1 = COPY %4(s32)
182...
183
184# Unmerge a constant into a bunch of smaller constant.
185# Constant is 0x0102030405060708090a0b0c0d0e0f10 and we break it down into
186# bytes:
187# cst1 0x10
188# cst2 0x0f
189# cst3 0x0e
190# ...
191---
192name:            test_combine_unmerge_cst
193body:             |
194  bb.1:
195    ; CHECK-LABEL: name: test_combine_unmerge_cst
196    ; CHECK: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 16
197    ; CHECK: [[C1:%[0-9]+]]:_(s8) = G_CONSTANT i8 15
198    ; CHECK: [[C2:%[0-9]+]]:_(s8) = G_CONSTANT i8 14
199    ; CHECK: [[C3:%[0-9]+]]:_(s8) = G_CONSTANT i8 13
200    ; CHECK: [[C4:%[0-9]+]]:_(s8) = G_CONSTANT i8 12
201    ; CHECK: [[C5:%[0-9]+]]:_(s8) = G_CONSTANT i8 11
202    ; CHECK: [[C6:%[0-9]+]]:_(s8) = G_CONSTANT i8 10
203    ; CHECK: [[C7:%[0-9]+]]:_(s8) = G_CONSTANT i8 9
204    ; CHECK: [[C8:%[0-9]+]]:_(s8) = G_CONSTANT i8 8
205    ; CHECK: [[C9:%[0-9]+]]:_(s8) = G_CONSTANT i8 7
206    ; CHECK: [[C10:%[0-9]+]]:_(s8) = G_CONSTANT i8 6
207    ; CHECK: [[C11:%[0-9]+]]:_(s8) = G_CONSTANT i8 5
208    ; CHECK: [[C12:%[0-9]+]]:_(s8) = G_CONSTANT i8 4
209    ; CHECK: [[C13:%[0-9]+]]:_(s8) = G_CONSTANT i8 3
210    ; CHECK: [[C14:%[0-9]+]]:_(s8) = G_CONSTANT i8 2
211    ; CHECK: [[C15:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
212    ; CHECK: $b0 = COPY [[C]](s8)
213    ; CHECK: $b1 = COPY [[C1]](s8)
214    ; CHECK: $b2 = COPY [[C2]](s8)
215    ; CHECK: $b3 = COPY [[C3]](s8)
216    ; CHECK: $b4 = COPY [[C4]](s8)
217    ; CHECK: $b5 = COPY [[C5]](s8)
218    ; CHECK: $b6 = COPY [[C6]](s8)
219    ; CHECK: $b7 = COPY [[C7]](s8)
220    ; CHECK: $b8 = COPY [[C8]](s8)
221    ; CHECK: $b9 = COPY [[C9]](s8)
222    ; CHECK: $b10 = COPY [[C10]](s8)
223    ; CHECK: $b11 = COPY [[C11]](s8)
224    ; CHECK: $b12 = COPY [[C12]](s8)
225    ; CHECK: $b13 = COPY [[C13]](s8)
226    ; CHECK: $b14 = COPY [[C14]](s8)
227    ; CHECK: $b15 = COPY [[C15]](s8)
228    %0:_(s128) = G_CONSTANT i128 1339673755198158349044581307228491536
229    %1:_(s8),%2:_(s8),%3:_(s8),%4:_(s8),%5:_(s8),%6:_(s8),%7:_(s8),%8:_(s8),%9:_(s8),%10:_(s8),%11:_(s8),%12:_(s8),%13:_(s8),%14:_(s8),%15:_(s8),%16:_(s8) = G_UNMERGE_VALUES %0(s128)
230    $b0 = COPY %1(s8)
231    $b1 = COPY %2(s8)
232    $b2 = COPY %3(s8)
233    $b3 = COPY %4(s8)
234    $b4 = COPY %5(s8)
235    $b5 = COPY %6(s8)
236    $b6 = COPY %7(s8)
237    $b7 = COPY %8(s8)
238    $b8 = COPY %9(s8)
239    $b9 = COPY %10(s8)
240    $b10 = COPY %11(s8)
241    $b11 = COPY %12(s8)
242    $b12 = COPY %13(s8)
243    $b13 = COPY %14(s8)
244    $b14 = COPY %15(s8)
245    $b15 = COPY %16(s8)
246...
247
248# Unmerge a constant on a non-power of 2 type into a bunch of smaller constant.
249# Constant is a 3 | 2 | 1 in chunks of 13-bit.
250---
251name:            test_combine_unmerge_cst_36bit
252body:             |
253  bb.1:
254    ; CHECK-LABEL: name: test_combine_unmerge_cst_36bit
255    ; CHECK: [[C:%[0-9]+]]:_(s13) = G_CONSTANT i13 1
256    ; CHECK: [[C1:%[0-9]+]]:_(s13) = G_CONSTANT i13 2
257    ; CHECK: [[C2:%[0-9]+]]:_(s13) = G_CONSTANT i13 3
258    ; CHECK: [[ZEXT:%[0-9]+]]:_(s16) = G_ZEXT [[C]](s13)
259    ; CHECK: [[ZEXT1:%[0-9]+]]:_(s16) = G_ZEXT [[C1]](s13)
260    ; CHECK: [[ZEXT2:%[0-9]+]]:_(s16) = G_ZEXT [[C2]](s13)
261    ; CHECK: $h0 = COPY [[ZEXT]](s16)
262    ; CHECK: $h1 = COPY [[ZEXT1]](s16)
263    ; CHECK: $h2 = COPY [[ZEXT2]](s16)
264    %0:_(s39) = G_CONSTANT i39 201342977
265    %1:_(s13),%2:_(s13),%3:_(s13) = G_UNMERGE_VALUES %0(s39)
266    %4:_(s16) = G_ZEXT %1(s13)
267    %5:_(s16) = G_ZEXT %2(s13)
268    %6:_(s16) = G_ZEXT %3(s13)
269    $h0 = COPY %4(s16)
270    $h1 = COPY %5(s16)
271    $h2 = COPY %6(s16)
272...
273
274# Unmerge floating point constant.
275---
276name:            test_combine_unmerge_fpcst
277body:             |
278  bb.1:
279    ; CHECK-LABEL: name: test_combine_unmerge_fpcst
280    ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 1
281    ; CHECK: [[C1:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
282    ; CHECK: [[C2:%[0-9]+]]:_(s16) = G_CONSTANT i16 3
283    ; CHECK: [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 4
284    ; CHECK: $h0 = COPY [[C]](s16)
285    ; CHECK: $h1 = COPY [[C1]](s16)
286    ; CHECK: $h2 = COPY [[C2]](s16)
287    ; CHECK: $h3 = COPY [[C3]](s16)
288    %0:_(s64) = G_FCONSTANT double 0x0004000300020001
289    %1:_(s16),%2:_(s16),%3:_(s16),%4:_(s16) = G_UNMERGE_VALUES %0(s64)
290    $h0 = COPY %1(s16)
291    $h1 = COPY %2(s16)
292    $h2 = COPY %3(s16)
293    $h3 = COPY %4(s16)
294...
295
296# Transform unmerge into trunc when only the first definition is live.
297---
298name:            test_combine_unmerge_dead_to_trunc
299body:             |
300  bb.1:
301    ; CHECK-LABEL: name: test_combine_unmerge_dead_to_trunc
302    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
303    ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
304    ; CHECK: $h0 = COPY [[TRUNC]](s16)
305    %0:_(s64) = COPY $x0
306    %1:_(s16),%2:_(s16),%3:_(s16),%4:_(s16) = G_UNMERGE_VALUES %0(s64)
307    $h0 = COPY %1(s16)
308...
309
310# Don't transform unmerge into trunc when middle lanes are live.
311---
312name:            test_dont_combine_unmerge_dead_to_trunc
313body:             |
314  bb.1:
315    ; CHECK-LABEL: name: test_dont_combine_unmerge_dead_to_trunc
316    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
317    ; CHECK: [[UV:%[0-9]+]]:_(s16), [[UV1:%[0-9]+]]:_(s16), [[UV2:%[0-9]+]]:_(s16), [[UV3:%[0-9]+]]:_(s16) = G_UNMERGE_VALUES [[COPY]](s64)
318    ; CHECK: $h0 = COPY [[UV2]](s16)
319    %0:_(s64) = COPY $x0
320    %1:_(s16),%2:_(s16),%3:_(s16),%4:_(s16) = G_UNMERGE_VALUES %0(s64)
321    $h0 = COPY %3(s16)
322...
323
324# Transform unmerge into trunc when only the first definition is live, even
325# if the input and output types are vectors.
326---
327name:            test_combine_unmerge_dead_to_trunc_vec_in_n_out
328body:             |
329  bb.1:
330    ; CHECK-LABEL: name: test_combine_unmerge_dead_to_trunc_vec_in_n_out
331    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $x0
332    ; CHECK: [[BITCAST:%[0-9]+]]:_(s64) = G_BITCAST [[COPY]](<2 x s32>)
333    ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[BITCAST]](s64)
334    ; CHECK: [[BITCAST1:%[0-9]+]]:_(<2 x s16>) = G_BITCAST [[TRUNC]](s32)
335    ; CHECK: $w0 = COPY [[BITCAST1]](<2 x s16>)
336    %0:_(<2 x s32>) = COPY $x0
337    %1:_(<2 x s16>),%2:_(<2 x s16>) = G_UNMERGE_VALUES %0(<2 x s32>)
338    $w0 = COPY %1(<2 x s16>)
339...
340
341# Transform unmerge into trunc when only the first definition is live, even
342# if the input type is vector.
343---
344name:            test_combine_unmerge_dead_to_trunc_vec_in
345body:             |
346  bb.1:
347    ; CHECK-LABEL: name: test_combine_unmerge_dead_to_trunc_vec_in
348    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $x0
349    ; CHECK: [[BITCAST:%[0-9]+]]:_(s64) = G_BITCAST [[COPY]](<2 x s32>)
350    ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[BITCAST]](s64)
351    ; CHECK: $h0 = COPY [[TRUNC]](s16)
352    %0:_(<2 x s32>) = COPY $x0
353    %1:_(s16),%2:_(s16),%3:_(s16),%4:_(s16) = G_UNMERGE_VALUES %0(<2 x s32>)
354    $h0 = COPY %1(s16)
355...
356
357# Transform unmerge into trunc when only the first definition is live, even
358# if the output type are vector.
359---
360name:            test_combine_unmerge_dead_to_trunc_vec_out
361body:             |
362  bb.1:
363    ; CHECK-LABEL: name: test_combine_unmerge_dead_to_trunc_vec_out
364    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
365    ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
366    ; CHECK: [[BITCAST:%[0-9]+]]:_(<2 x s16>) = G_BITCAST [[TRUNC]](s32)
367    ; CHECK: $w0 = COPY [[BITCAST]](<2 x s16>)
368    %0:_(s64) = COPY $x0
369    %1:_(<2 x s16>),%2:_(<2 x s16>) = G_UNMERGE_VALUES %0(s64)
370    $w0 = COPY %1(<2 x s16>)
371...
372
373# Transform unmerge(zext) into zext.
374# In that test, the source of the zext is same size as the first definition
375# of the unmerge. Therefore a we can just reuse the input of the zext for
376# this definition.
377---
378name:            test_combine_unmerge_zext_to_zext_same_size
379body:             |
380  bb.1:
381    ; CHECK-LABEL: name: test_combine_unmerge_zext_to_zext_same_size
382    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
383    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
384    ; CHECK: $w0 = COPY [[COPY]](s32)
385    ; CHECK: $w1 = COPY [[C]](s32)
386    %0:_(s32) = COPY $w0
387    %3:_(s64) = G_ZEXT %0(s32)
388    %1:_(s32),%2:_(s32) = G_UNMERGE_VALUES %3(s64)
389    $w0 = COPY %1(s32)
390    $w1 = COPY %2(s32)
391...
392
393# Transform unmerge(zext) into zext.
394# In that test, the source of the zext is smaller than the first definition
395# of the unmerge. Therefore a G_ZEXT is required.
396---
397name:            test_combine_unmerge_zext_to_zext
398body:             |
399  bb.1:
400    ; CHECK-LABEL: name: test_combine_unmerge_zext_to_zext
401    ; CHECK: [[COPY:%[0-9]+]]:_(s8) = COPY $b0
402    ; CHECK: [[ZEXT:%[0-9]+]]:_(s16) = G_ZEXT [[COPY]](s8)
403    ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
404    ; CHECK: $h0 = COPY [[ZEXT]](s16)
405    ; CHECK: $h1 = COPY [[C]](s16)
406    ; CHECK: $h2 = COPY [[C]](s16)
407    ; CHECK: $h3 = COPY [[C]](s16)
408    %0:_(s8) = COPY $b0
409    %3:_(s64) = G_ZEXT %0(s8)
410    %1:_(s16),%2:_(s16),%4:_(s16),%5:_(s16) = G_UNMERGE_VALUES %3(s64)
411    $h0 = COPY %1(s16)
412    $h1 = COPY %2(s16)
413    $h2 = COPY %4(s16)
414    $h3 = COPY %5(s16)
415...
416
417# Check that we don't apply the unmerge(zext) to zext transformation
418# when the first destination of the unmerge is smaller than the source
419# of the zext.
420---
421name:            test_dont_combine_unmerge_zext_to_zext_src_bigger
422body:             |
423  bb.1:
424    ; CHECK-LABEL: name: test_dont_combine_unmerge_zext_to_zext_src_bigger
425    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
426    ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
427    ; CHECK: [[UV:%[0-9]+]]:_(s16), [[UV1:%[0-9]+]]:_(s16), [[UV2:%[0-9]+]]:_(s16), [[UV3:%[0-9]+]]:_(s16) = G_UNMERGE_VALUES [[ZEXT]](s64)
428    ; CHECK: $h0 = COPY [[UV]](s16)
429    ; CHECK: $h1 = COPY [[UV1]](s16)
430    ; CHECK: $h2 = COPY [[UV2]](s16)
431    ; CHECK: $h3 = COPY [[UV3]](s16)
432    %0:_(s32) = COPY $w0
433    %3:_(s64) = G_ZEXT %0(s32)
434    %1:_(s16),%2:_(s16),%4:_(s16),%5:_(s16) = G_UNMERGE_VALUES %3(s64)
435    $h0 = COPY %1(s16)
436    $h1 = COPY %2(s16)
437    $h2 = COPY %4(s16)
438    $h3 = COPY %5(s16)
439...
440
441# Check that we don't apply the unmerge(zext) to zext transformation
442# when the input zext deals with a vector type.
443---
444name:            test_dont_combine_unmerge_zext_to_zext_src_vector
445body:             |
446  bb.1:
447    ; CHECK-LABEL: name: test_dont_combine_unmerge_zext_to_zext_src_vector
448    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $w0
449    ; CHECK: [[ZEXT:%[0-9]+]]:_(<2 x s32>) = G_ZEXT [[COPY]](<2 x s16>)
450    ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[ZEXT]](<2 x s32>)
451    ; CHECK: $w0 = COPY [[UV]](s32)
452    ; CHECK: $w1 = COPY [[UV1]](s32)
453    %0:_(<2 x s16>) = COPY $w0
454    %3:_(<2 x s32>) = G_ZEXT %0(<2 x s16>)
455    %1:_(s32),%2:_(s32) = G_UNMERGE_VALUES %3(<2 x s32>)
456    $w0 = COPY %1(s32)
457    $w1 = COPY %2(s32)
458...
459
460# Check that we don't apply the unmerge(zext) to zext transformation
461# when the destination type is a vector type.
462# We could actually handle this case but we would need to insert a cast.
463---
464name:            test_dont_combine_unmerge_zext_to_zext_dst_vector
465body:             |
466  bb.1:
467    ; CHECK-LABEL: name: test_dont_combine_unmerge_zext_to_zext_dst_vector
468    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
469    ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
470    ; CHECK: [[UV:%[0-9]+]]:_(<2 x s16>), [[UV1:%[0-9]+]]:_(<2 x s16>) = G_UNMERGE_VALUES [[ZEXT]](s64)
471    ; CHECK: $w0 = COPY [[UV]](<2 x s16>)
472    ; CHECK: $w1 = COPY [[UV1]](<2 x s16>)
473    %0:_(s32) = COPY $w0
474    %3:_(s64) = G_ZEXT %0(s32)
475    %1:_(<2 x s16>),%2:_(<2 x s16>) = G_UNMERGE_VALUES %3(s64)
476    $w0 = COPY %1(<2 x s16>)
477    $w1 = COPY %2(<2 x s16>)
478...
479