1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -run-pass=legalizer %s -o - | FileCheck -check-prefix=GFX9 %s
4 # The G_ZEXT and G_SHL will be scalarized, introducing a
5 # G_UNMERGE_VALUES of G_BUILD_VECTOR. The artifact combiner should
8 name: revisit_build_vector_unmerge_user
9 tracksRegLiveness: true
14 ; GFX9-LABEL: name: revisit_build_vector_unmerge_user
15 ; GFX9: liveins: $vgpr0_vgpr1
17 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
18 ; GFX9-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
19 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
20 ; GFX9-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[UV]](s32)
21 ; GFX9-NEXT: [[ZEXT1:%[0-9]+]]:_(s64) = G_ZEXT [[UV1]](s32)
22 ; GFX9-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s32)
23 ; GFX9-NEXT: [[SHL1:%[0-9]+]]:_(s64) = G_SHL [[ZEXT1]], [[C]](s32)
24 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[SHL]](s64), [[SHL1]](s64)
25 ; GFX9-NEXT: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[BUILD_VECTOR]](<2 x s64>)
26 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
27 %1:_(s32) = G_CONSTANT i32 2
28 %2:_(<2 x s32>) = G_BUILD_VECTOR %1, %1
29 %3:_(<2 x s64>) = G_ZEXT %0
30 %4:_(<2 x s64>) = G_SHL %3, %2
31 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %4
38 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
40 ; GFX9-LABEL: name: copy_scalar
41 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
43 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
44 ; GFX9-NEXT: $vgpr2_vgpr3 = COPY [[COPY]](s64)
45 %0:_(s64) = COPY $vgpr0_vgpr1
46 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(s64)
47 %3:_(s64) = G_MERGE_VALUES %1, %2
52 name: copy_vector_using_elements
55 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
57 ; GFX9-LABEL: name: copy_vector_using_elements
58 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
60 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
61 ; GFX9-NEXT: $vgpr2_vgpr3 = COPY [[COPY]](<2 x s32>)
62 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
63 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
64 %3:_(<2 x s32>) = G_BUILD_VECTOR %1, %2
69 name: copy_vector_using_subvectors
72 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
74 ; GFX9-LABEL: name: copy_vector_using_subvectors
75 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
77 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<4 x s16>) = COPY $vgpr0_vgpr1
78 ; GFX9-NEXT: $vgpr2_vgpr3 = COPY [[COPY]](<4 x s16>)
79 %0:_(<4 x s16>) = COPY $vgpr0_vgpr1
80 %1:_(<2 x s16>), %2:_(<2 x s16>) = G_UNMERGE_VALUES %0(<4 x s16>)
81 %3:_(<4 x s16>) = G_CONCAT_VECTORS %1, %2
86 name: shuffle_vector_elements
89 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
91 ; GFX9-LABEL: name: shuffle_vector_elements
92 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
94 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
95 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
96 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[UV1]](s32), [[UV]](s32)
97 ; GFX9-NEXT: $vgpr2_vgpr3 = COPY [[BUILD_VECTOR]](<2 x s32>)
98 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
99 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
100 %3:_(<2 x s32>) = G_BUILD_VECTOR %2, %1
101 $vgpr2_vgpr3= COPY %3
108 liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3_vgpr4
110 ; GFX9-LABEL: name: insert_element
111 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3_vgpr4
113 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
114 ; GFX9-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr2
115 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
116 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[UV]](s32), [[COPY1]](s32)
117 ; GFX9-NEXT: $vgpr2_vgpr3 = COPY [[BUILD_VECTOR]](<2 x s32>)
118 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
119 %1:_(s32) = COPY $vgpr2
120 %2:_(s32), %3:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
121 %4:_(<2 x s32>) = G_BUILD_VECTOR %2, %1
122 $vgpr2_vgpr3= COPY %4
126 name: unmerge_to_sub_vectors
129 liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
131 ; GFX9-LABEL: name: unmerge_to_sub_vectors
132 ; GFX9: liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
134 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
135 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(<2 x s32>), [[UV1:%[0-9]+]]:_(<2 x s32>) = G_UNMERGE_VALUES [[COPY]](<4 x s32>)
136 ; GFX9-NEXT: $vgpr4_vgpr5 = COPY [[UV]](<2 x s32>)
137 ; GFX9-NEXT: $vgpr6_vgpr7 = COPY [[UV1]](<2 x s32>)
138 %0:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
139 %1:_(s32), %2:_(s32), %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %0(<4 x s32>)
140 %5:_(<2 x s32>) = G_BUILD_VECTOR %1, %2
141 %6:_(<2 x s32>) = G_BUILD_VECTOR %3, %4
142 $vgpr4_vgpr5= COPY %5
143 $vgpr6_vgpr7= COPY %6
147 name: cant_unmerge_to_sub_vectors
150 liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
152 ; GFX9-LABEL: name: cant_unmerge_to_sub_vectors
153 ; GFX9: liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
155 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
156 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<4 x s32>)
157 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[UV]](s32), [[UV3]](s32)
158 ; GFX9-NEXT: [[BUILD_VECTOR1:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[UV1]](s32), [[UV2]](s32)
159 ; GFX9-NEXT: $vgpr4_vgpr5 = COPY [[BUILD_VECTOR]](<2 x s32>)
160 ; GFX9-NEXT: $vgpr6_vgpr7 = COPY [[BUILD_VECTOR1]](<2 x s32>)
161 %0:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
162 %1:_(s32), %2:_(s32), %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %0(<4 x s32>)
163 %5:_(<2 x s32>) = G_BUILD_VECTOR %1, %4
164 %6:_(<2 x s32>) = G_BUILD_VECTOR %2, %3
165 $vgpr4_vgpr5= COPY %5
166 $vgpr6_vgpr7= COPY %6
173 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7
175 ; GFX9-LABEL: name: concat
176 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7
178 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
179 ; GFX9-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
180 ; GFX9-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s32>) = G_CONCAT_VECTORS [[COPY]](<2 x s32>), [[COPY1]](<2 x s32>)
181 ; GFX9-NEXT: $vgpr4_vgpr5_vgpr6_vgpr7 = COPY [[CONCAT_VECTORS]](<4 x s32>)
182 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
183 %1:_(<2 x s32>) = COPY $vgpr2_vgpr3
184 %2:_(s32), %3:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
185 %4:_(s32), %5:_(s32) = G_UNMERGE_VALUES %1(<2 x s32>)
186 %6:_(<4 x s32>) = G_BUILD_VECTOR %2, %3, %4, %5
187 $vgpr4_vgpr5_vgpr6_vgpr7= COPY %6
191 name: concat_same_vector
194 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3_vgpr4_vgpr5
196 ; GFX9-LABEL: name: concat_same_vector
197 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3_vgpr4_vgpr5
199 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
200 ; GFX9-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s32>) = G_CONCAT_VECTORS [[COPY]](<2 x s32>), [[COPY]](<2 x s32>)
201 ; GFX9-NEXT: $vgpr2_vgpr3_vgpr4_vgpr5 = COPY [[CONCAT_VECTORS]](<4 x s32>)
202 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
203 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
204 %3:_(<4 x s32>) = G_BUILD_VECTOR %1, %2, %1, %2
205 $vgpr2_vgpr3_vgpr4_vgpr5= COPY %3
209 name: shuffle_not_concat
212 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7
214 ; GFX9-LABEL: name: shuffle_not_concat
215 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7
217 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
218 ; GFX9-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
219 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
220 ; GFX9-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>)
221 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[UV2]](s32), [[UV]](s32), [[UV1]](s32), [[UV3]](s32)
222 ; GFX9-NEXT: $vgpr4_vgpr5_vgpr6_vgpr7 = COPY [[BUILD_VECTOR]](<4 x s32>)
223 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
224 %1:_(<2 x s32>) = COPY $vgpr2_vgpr3
225 %2:_(s32), %3:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
226 %4:_(s32), %5:_(s32) = G_UNMERGE_VALUES %1(<2 x s32>)
227 %6:_(<4 x s32>) = G_BUILD_VECTOR %4, %2, %3, %5
228 $vgpr4_vgpr5_vgpr6_vgpr7= COPY %6
235 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5_vgpr6_vgpr7_vgpr8_vgpr9
237 ; GFX9-LABEL: name: not_a_concat
238 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5_vgpr6_vgpr7_vgpr8_vgpr9
240 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
241 ; GFX9-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
242 ; GFX9-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr4
243 ; GFX9-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
244 ; GFX9-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>)
245 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<5 x s32>) = G_BUILD_VECTOR [[UV]](s32), [[UV1]](s32), [[UV2]](s32), [[UV3]](s32), [[COPY2]](s32)
246 ; GFX9-NEXT: $vgpr5_vgpr6_vgpr7_vgpr8_vgpr9 = COPY [[BUILD_VECTOR]](<5 x s32>)
247 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
248 %1:_(<2 x s32>) = COPY $vgpr2_vgpr3
249 %2:_(s32) = COPY $vgpr4
250 %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
251 %5:_(s32), %6:_(s32) = G_UNMERGE_VALUES %1(<2 x s32>)
252 %7:_(<5 x s32>) = G_BUILD_VECTOR %3, %4, %5, %6, %2
253 $vgpr5_vgpr6_vgpr7_vgpr8_vgpr9= COPY %7
257 name: value_finder_look_through_copy
260 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
262 ; GFX9-LABEL: name: value_finder_look_through_copy
263 ; GFX9: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
265 ; GFX9-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
266 ; GFX9-NEXT: $vgpr2_vgpr3 = COPY [[COPY]](<2 x s32>)
267 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
268 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(<2 x s32>)
270 %4:_(<2 x s32>) = G_BUILD_VECTOR %3, %2
271 $vgpr2_vgpr3= COPY %4