1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=amdgpu-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck -check-prefix=GFX6 %s
3 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -run-pass=amdgpu-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck -check-prefix=GFX9 %s
6 name: narrow_shl_s32_by_2_from_zext_s16
7 tracksRegLiveness: true
12 ; GFX6-LABEL: name: narrow_shl_s32_by_2_from_zext_s16
13 ; GFX6: liveins: $vgpr0
15 ; GFX6-NEXT: %argument:_(s32) = COPY $vgpr0
16 ; GFX6-NEXT: %narrow:_(s16) = G_TRUNC %argument(s32)
17 ; GFX6-NEXT: %masklow14:_(s16) = G_CONSTANT i16 16383
18 ; GFX6-NEXT: %masked:_(s16) = G_AND %narrow, %masklow14
19 ; GFX6-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
20 ; GFX6-NEXT: [[SHL:%[0-9]+]]:_(s16) = G_SHL %masked, [[C]](s16)
21 ; GFX6-NEXT: %shl:_(s32) = G_ZEXT [[SHL]](s16)
22 ; GFX6-NEXT: $vgpr0 = COPY %shl(s32)
24 ; GFX9-LABEL: name: narrow_shl_s32_by_2_from_zext_s16
25 ; GFX9: liveins: $vgpr0
27 ; GFX9-NEXT: %argument:_(s32) = COPY $vgpr0
28 ; GFX9-NEXT: %narrow:_(s16) = G_TRUNC %argument(s32)
29 ; GFX9-NEXT: %masklow14:_(s16) = G_CONSTANT i16 16383
30 ; GFX9-NEXT: %masked:_(s16) = G_AND %narrow, %masklow14
31 ; GFX9-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
32 ; GFX9-NEXT: [[SHL:%[0-9]+]]:_(s16) = G_SHL %masked, [[C]](s16)
33 ; GFX9-NEXT: %shl:_(s32) = G_ZEXT [[SHL]](s16)
34 ; GFX9-NEXT: $vgpr0 = COPY %shl(s32)
35 %argument:_(s32) = COPY $vgpr0
36 %narrow:_(s16) = G_TRUNC %argument
37 %masklow14:_(s16) = G_CONSTANT i16 16383
38 %masked:_(s16) = G_AND %narrow, %masklow14
39 %extend:_(s32) = G_ZEXT %masked
40 %shiftamt:_(s32) = G_CONSTANT i32 2
41 %shl:_(s32) = G_SHL %extend, %shiftamt
46 name: narrow_shl_s64_by_2_from_zext_s16
47 tracksRegLiveness: true
52 ; GFX6-LABEL: name: narrow_shl_s64_by_2_from_zext_s16
53 ; GFX6: liveins: $vgpr0
55 ; GFX6-NEXT: %argument:_(s32) = COPY $vgpr0
56 ; GFX6-NEXT: %narrow:_(s16) = G_TRUNC %argument(s32)
57 ; GFX6-NEXT: %masklow14:_(s16) = G_CONSTANT i16 16383
58 ; GFX6-NEXT: %masked:_(s16) = G_AND %narrow, %masklow14
59 ; GFX6-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
60 ; GFX6-NEXT: [[SHL:%[0-9]+]]:_(s16) = G_SHL %masked, [[C]](s16)
61 ; GFX6-NEXT: %shl:_(s64) = G_ZEXT [[SHL]](s16)
62 ; GFX6-NEXT: $vgpr0_vgpr1 = COPY %shl(s64)
64 ; GFX9-LABEL: name: narrow_shl_s64_by_2_from_zext_s16
65 ; GFX9: liveins: $vgpr0
67 ; GFX9-NEXT: %argument:_(s32) = COPY $vgpr0
68 ; GFX9-NEXT: %narrow:_(s16) = G_TRUNC %argument(s32)
69 ; GFX9-NEXT: %masklow14:_(s16) = G_CONSTANT i16 16383
70 ; GFX9-NEXT: %masked:_(s16) = G_AND %narrow, %masklow14
71 ; GFX9-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
72 ; GFX9-NEXT: [[SHL:%[0-9]+]]:_(s16) = G_SHL %masked, [[C]](s16)
73 ; GFX9-NEXT: %shl:_(s64) = G_ZEXT [[SHL]](s16)
74 ; GFX9-NEXT: $vgpr0_vgpr1 = COPY %shl(s64)
75 %argument:_(s32) = COPY $vgpr0
76 %narrow:_(s16) = G_TRUNC %argument
77 %masklow14:_(s16) = G_CONSTANT i16 16383
78 %masked:_(s16) = G_AND %narrow, %masklow14
79 %extend:_(s64) = G_ZEXT %masked
80 %shiftamt:_(s32) = G_CONSTANT i32 2
81 %shl:_(s64) = G_SHL %extend, %shiftamt
82 $vgpr0_vgpr1 = COPY %shl
86 name: narrow_shl_s16_by_2_from_zext_s8
87 tracksRegLiveness: true
92 ; GFX6-LABEL: name: narrow_shl_s16_by_2_from_zext_s8
93 ; GFX6: liveins: $vgpr0
95 ; GFX6-NEXT: %argument:_(s32) = COPY $vgpr0
96 ; GFX6-NEXT: %narrow:_(s8) = G_TRUNC %argument(s32)
97 ; GFX6-NEXT: %masklow6:_(s8) = G_CONSTANT i8 63
98 ; GFX6-NEXT: %masked:_(s8) = G_AND %narrow, %masklow6
99 ; GFX6-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 2
100 ; GFX6-NEXT: [[SHL:%[0-9]+]]:_(s8) = G_SHL %masked, [[C]](s8)
101 ; GFX6-NEXT: %result:_(s32) = G_ZEXT [[SHL]](s8)
102 ; GFX6-NEXT: $vgpr0 = COPY %result(s32)
104 ; GFX9-LABEL: name: narrow_shl_s16_by_2_from_zext_s8
105 ; GFX9: liveins: $vgpr0
107 ; GFX9-NEXT: %argument:_(s32) = COPY $vgpr0
108 ; GFX9-NEXT: %narrow:_(s8) = G_TRUNC %argument(s32)
109 ; GFX9-NEXT: %masklow6:_(s8) = G_CONSTANT i8 63
110 ; GFX9-NEXT: %masked:_(s8) = G_AND %narrow, %masklow6
111 ; GFX9-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 2
112 ; GFX9-NEXT: [[SHL:%[0-9]+]]:_(s8) = G_SHL %masked, [[C]](s8)
113 ; GFX9-NEXT: %result:_(s32) = G_ZEXT [[SHL]](s8)
114 ; GFX9-NEXT: $vgpr0 = COPY %result(s32)
115 %argument:_(s32) = COPY $vgpr0
116 %narrow:_(s8) = G_TRUNC %argument
117 %masklow6:_(s8) = G_CONSTANT i8 63
118 %masked:_(s8) = G_AND %narrow, %masklow6
119 %extend:_(s16) = G_ZEXT %masked
120 %shiftamt:_(s16) = G_CONSTANT i16 2
121 %shl:_(s16) = G_SHL %extend, %shiftamt
122 %result:_(s32) = G_ANYEXT %shl
123 $vgpr0 = COPY %result
127 name: narrow_shl_v2s32_by_2_from_zext_v2s16
128 tracksRegLiveness: true
133 ; GFX6-LABEL: name: narrow_shl_v2s32_by_2_from_zext_v2s16
134 ; GFX6: liveins: $vgpr0
136 ; GFX6-NEXT: %narrow:_(<2 x s16>) = COPY $vgpr0
137 ; GFX6-NEXT: %masklow14:_(s16) = G_CONSTANT i16 16383
138 ; GFX6-NEXT: %masklow14vec:_(<2 x s16>) = G_BUILD_VECTOR %masklow14(s16), %masklow14(s16)
139 ; GFX6-NEXT: %masked:_(<2 x s16>) = G_AND %narrow, %masklow14vec
140 ; GFX6-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
141 ; GFX6-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[C]](s16), [[C]](s16)
142 ; GFX6-NEXT: [[SHL:%[0-9]+]]:_(<2 x s16>) = G_SHL %masked, [[BUILD_VECTOR]](<2 x s16>)
143 ; GFX6-NEXT: %shl:_(<2 x s32>) = G_ZEXT [[SHL]](<2 x s16>)
144 ; GFX6-NEXT: $vgpr0_vgpr1 = COPY %shl(<2 x s32>)
146 ; GFX9-LABEL: name: narrow_shl_v2s32_by_2_from_zext_v2s16
147 ; GFX9: liveins: $vgpr0
149 ; GFX9-NEXT: %narrow:_(<2 x s16>) = COPY $vgpr0
150 ; GFX9-NEXT: %masklow14:_(s16) = G_CONSTANT i16 16383
151 ; GFX9-NEXT: %masklow14vec:_(<2 x s16>) = G_BUILD_VECTOR %masklow14(s16), %masklow14(s16)
152 ; GFX9-NEXT: %masked:_(<2 x s16>) = G_AND %narrow, %masklow14vec
153 ; GFX9-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 2
154 ; GFX9-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s16>) = G_BUILD_VECTOR [[C]](s16), [[C]](s16)
155 ; GFX9-NEXT: [[SHL:%[0-9]+]]:_(<2 x s16>) = G_SHL %masked, [[BUILD_VECTOR]](<2 x s16>)
156 ; GFX9-NEXT: %shl:_(<2 x s32>) = G_ZEXT [[SHL]](<2 x s16>)
157 ; GFX9-NEXT: $vgpr0_vgpr1 = COPY %shl(<2 x s32>)
158 %narrow:_(<2 x s16>) = COPY $vgpr0
159 %masklow14:_(s16) = G_CONSTANT i16 16383
160 %masklow14vec:_(<2 x s16>) = G_BUILD_VECTOR %masklow14, %masklow14
161 %masked:_(<2 x s16>) = G_AND %narrow, %masklow14vec
162 %extend:_(<2 x s32>) = G_ZEXT %masked
163 %shiftamt:_(s32) = G_CONSTANT i32 2
164 %shiftamtvec:_(<2 x s32>) = G_BUILD_VECTOR %shiftamt, %shiftamt
165 %shl:_(<2 x s32>) = G_SHL %extend, %shiftamtvec
166 $vgpr0_vgpr1 = COPY %shl
170 name: narrow_shl_v2s64_by_2_from_anyext_v2s32
171 tracksRegLiveness: true
174 liveins: $vgpr0_vgpr1
176 ; GFX6-LABEL: name: narrow_shl_v2s64_by_2_from_anyext_v2s32
177 ; GFX6: liveins: $vgpr0_vgpr1
179 ; GFX6-NEXT: %narrow:_(<2 x s32>) = COPY $vgpr0_vgpr1
180 ; GFX6-NEXT: %masklow30:_(s32) = G_CONSTANT i32 1073741823
181 ; GFX6-NEXT: %masklow30vec:_(<2 x s32>) = G_BUILD_VECTOR %masklow30(s32), %masklow30(s32)
182 ; GFX6-NEXT: %masked:_(<2 x s32>) = G_AND %narrow, %masklow30vec
183 ; GFX6-NEXT: %shiftamt:_(s32) = G_CONSTANT i32 2
184 ; GFX6-NEXT: %shiftamtvec:_(<2 x s32>) = G_BUILD_VECTOR %shiftamt(s32), %shiftamt(s32)
185 ; GFX6-NEXT: [[SHL:%[0-9]+]]:_(<2 x s32>) = G_SHL %masked, %shiftamtvec(<2 x s32>)
186 ; GFX6-NEXT: %shl:_(<2 x s64>) = G_ZEXT [[SHL]](<2 x s32>)
187 ; GFX6-NEXT: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %shl(<2 x s64>)
189 ; GFX9-LABEL: name: narrow_shl_v2s64_by_2_from_anyext_v2s32
190 ; GFX9: liveins: $vgpr0_vgpr1
192 ; GFX9-NEXT: %narrow:_(<2 x s32>) = COPY $vgpr0_vgpr1
193 ; GFX9-NEXT: %masklow30:_(s32) = G_CONSTANT i32 1073741823
194 ; GFX9-NEXT: %masklow30vec:_(<2 x s32>) = G_BUILD_VECTOR %masklow30(s32), %masklow30(s32)
195 ; GFX9-NEXT: %masked:_(<2 x s32>) = G_AND %narrow, %masklow30vec
196 ; GFX9-NEXT: %shiftamt:_(s32) = G_CONSTANT i32 2
197 ; GFX9-NEXT: %shiftamtvec:_(<2 x s32>) = G_BUILD_VECTOR %shiftamt(s32), %shiftamt(s32)
198 ; GFX9-NEXT: [[SHL:%[0-9]+]]:_(<2 x s32>) = G_SHL %masked, %shiftamtvec(<2 x s32>)
199 ; GFX9-NEXT: %shl:_(<2 x s64>) = G_ZEXT [[SHL]](<2 x s32>)
200 ; GFX9-NEXT: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %shl(<2 x s64>)
201 %narrow:_(<2 x s32>) = COPY $vgpr0_vgpr1
202 %masklow30:_(s32) = G_CONSTANT i32 1073741823
203 %masklow30vec:_(<2 x s32>) = G_BUILD_VECTOR %masklow30, %masklow30
204 %masked:_(<2 x s32>) = G_AND %narrow, %masklow30vec
205 %extend:_(<2 x s64>) = G_ANYEXT %masked
206 %shiftamt:_(s32) = G_CONSTANT i32 2
207 %shiftamtvec:_(<2 x s32>) = G_BUILD_VECTOR %shiftamt, %shiftamt
208 %shl:_(<2 x s64>) = G_SHL %extend, %shiftamtvec
209 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %shl
213 name: do_not_shl_s32_zero_by_16_from_zext_s16
214 tracksRegLiveness: true
220 ; GFX6-LABEL: name: do_not_shl_s32_zero_by_16_from_zext_s16
221 ; GFX6: liveins: $vgpr0
223 ; GFX6-NEXT: %extend:_(s32) = G_CONSTANT i32 0
224 ; GFX6-NEXT: $vgpr0 = COPY %extend(s32)
226 ; GFX9-LABEL: name: do_not_shl_s32_zero_by_16_from_zext_s16
227 ; GFX9: liveins: $vgpr0
229 ; GFX9-NEXT: %extend:_(s32) = G_CONSTANT i32 0
230 ; GFX9-NEXT: $vgpr0 = COPY %extend(s32)
231 %zero:_(s16) = G_CONSTANT i16 0
232 %extend:_(s32) = G_ZEXT %zero:_(s16)
233 %shiftamt:_(s16) = G_CONSTANT i16 16
234 %shl:_(s32) = G_SHL %extend, %shiftamt(s16)
239 name: do_not_shl_v2s32_zero_by_16_from_zext_v2s16
240 tracksRegLiveness: true
245 liveins: $vgpr0, $vgpr1
246 ; GFX6-LABEL: name: do_not_shl_v2s32_zero_by_16_from_zext_v2s16
247 ; GFX6: liveins: $vgpr0, $vgpr1
249 ; GFX6-NEXT: %zero:_(s16) = G_CONSTANT i16 0
250 ; GFX6-NEXT: %zerovector:_(<2 x s16>) = G_BUILD_VECTOR %zero(s16), %zero(s16)
251 ; GFX6-NEXT: %shiftamt:_(s16) = G_CONSTANT i16 16
252 ; GFX6-NEXT: %shiftamtvector:_(<2 x s16>) = G_BUILD_VECTOR %shiftamt(s16), %shiftamt(s16)
253 ; GFX6-NEXT: %extend:_(<2 x s32>) = G_ZEXT %zerovector(<2 x s16>)
254 ; GFX6-NEXT: %shl:_(<2 x s32>) = G_SHL %extend, %shiftamtvector(<2 x s16>)
255 ; GFX6-NEXT: $vgpr0_vgpr1 = COPY %shl(<2 x s32>)
257 ; GFX9-LABEL: name: do_not_shl_v2s32_zero_by_16_from_zext_v2s16
258 ; GFX9: liveins: $vgpr0, $vgpr1
260 ; GFX9-NEXT: %zero:_(s16) = G_CONSTANT i16 0
261 ; GFX9-NEXT: %zerovector:_(<2 x s16>) = G_BUILD_VECTOR %zero(s16), %zero(s16)
262 ; GFX9-NEXT: %shiftamt:_(s16) = G_CONSTANT i16 16
263 ; GFX9-NEXT: %shiftamtvector:_(<2 x s16>) = G_BUILD_VECTOR %shiftamt(s16), %shiftamt(s16)
264 ; GFX9-NEXT: %extend:_(<2 x s32>) = G_ZEXT %zerovector(<2 x s16>)
265 ; GFX9-NEXT: %shl:_(<2 x s32>) = G_SHL %extend, %shiftamtvector(<2 x s16>)
266 ; GFX9-NEXT: $vgpr0_vgpr1 = COPY %shl(<2 x s32>)
267 %zero:_(s16) = G_CONSTANT i16 0
268 %zerovector:_(<2 x s16>) = G_BUILD_VECTOR %zero, %zero:_(s16)
269 %shiftamt:_(s16) = G_CONSTANT i16 16
270 %shiftamtvector:_(<2 x s16>) = G_BUILD_VECTOR %shiftamt, %shiftamt:_(s16)
271 %extend:_(<2 x s32>) = G_ZEXT %zerovector:_(<2 x s16>)
272 %shl:_(<2 x s32>) = G_SHL %extend, %shiftamtvector
273 $vgpr0_vgpr1 = COPY %shl
277 name: do_not_shl_s32_by_16_from_zext_s16
278 tracksRegLiveness: true
284 ; GFX6-LABEL: name: do_not_shl_s32_by_16_from_zext_s16
285 ; GFX6: liveins: $vgpr0
287 ; GFX6-NEXT: %argument:_(s32) = COPY $vgpr0
288 ; GFX6-NEXT: %truncate:_(s16) = G_TRUNC %argument(s32)
289 ; GFX6-NEXT: %shiftamt:_(s16) = G_CONSTANT i16 16
290 ; GFX6-NEXT: %extend:_(s32) = G_ZEXT %truncate(s16)
291 ; GFX6-NEXT: %shl:_(s32) = G_SHL %extend, %shiftamt(s16)
292 ; GFX6-NEXT: $vgpr0 = COPY %shl(s32)
294 ; GFX9-LABEL: name: do_not_shl_s32_by_16_from_zext_s16
295 ; GFX9: liveins: $vgpr0
297 ; GFX9-NEXT: %argument:_(s32) = COPY $vgpr0
298 ; GFX9-NEXT: %truncate:_(s16) = G_TRUNC %argument(s32)
299 ; GFX9-NEXT: %shiftamt:_(s16) = G_CONSTANT i16 16
300 ; GFX9-NEXT: %extend:_(s32) = G_ZEXT %truncate(s16)
301 ; GFX9-NEXT: %shl:_(s32) = G_SHL %extend, %shiftamt(s16)
302 ; GFX9-NEXT: $vgpr0 = COPY %shl(s32)
303 %argument:_(s32) = COPY $vgpr0
304 %truncate:_(s16) = G_TRUNC %argument:_(s32)
305 %shiftamt:_(s16) = G_CONSTANT i16 16
306 %extend:_(s32) = G_ZEXT %truncate:_(s16)
307 %shl:_(s32) = G_SHL %extend, %shiftamt(s16)