[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / fold-readlane.mir
blobb76cf45c785f41b8d6650bc01c88229ed67fc5a5
1 # RUN: llc -march=amdgcn -run-pass si-fold-operands -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
3 # GCN-LABEL: name: fold-imm-readfirstlane{{$}}
4 # GCN: %1:sreg_32_xm0 = S_MOV_B32 123
5 ---
6 name: fold-imm-readfirstlane
7 tracksRegLiveness: true
8 body:             |
9   bb.0:
10     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
11     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
12     S_NOP 0, implicit %1
13 ...
15 # GCN-LABEL: name: fold-imm-readfirstlane-dbgvalue{{$}}
16 # GCN: %1:sreg_32_xm0 = S_MOV_B32 123
17 # GCN: DBG_VALUE %0:vgpr_32, 0, 0
18 ---
19 name: fold-imm-readfirstlane-dbgvalue
20 tracksRegLiveness: true
21 body:             |
22   bb.0:
23     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
24     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
25     DBG_VALUE %0, 0, 0
26     S_NOP 0, implicit %1
27 ...
29 # GCN-LABEL: name: fold-imm-readfirstlane-readfirstlane{{$}}
30 # GCN: %1:sreg_32_xm0 = S_MOV_B32 123
31 # GCN: %3:sreg_32_xm0 = COPY %1
33 ---
34 name: fold-imm-readfirstlane-readfirstlane
35 tracksRegLiveness: true
36 body:             |
37   bb.0:
38     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
39     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
40     %2:vgpr_32 = COPY %1
41     %3:sreg_32_xm0 = V_READFIRSTLANE_B32 %2, implicit $exec
42     S_NOP 0, implicit %3
43 ...
46 # GCN-LABEL: name: fold-copy-readfirstlane{{$}}
47 # GCN: %0:sreg_32_xm0 = COPY $sgpr10
48 # GCN: %2:sreg_32_xm0 = COPY %0
49 ---
50 name: fold-copy-readfirstlane
51 tracksRegLiveness: true
52 body:             |
53   bb.0:
54     liveins: $sgpr10
55     %0:sreg_32_xm0 = COPY $sgpr10
56     %1:vgpr_32 = COPY %0
57     %2:sreg_32_xm0 = V_READFIRSTLANE_B32 %1, implicit $exec
58     S_NOP 0, implicit %2
59 ...
61 # GCN-LABEL: name: no-fold-copy-readfirstlane-physreg0{{$}}
62 # GCN: %0:vgpr_32 = COPY $sgpr10
63 # GCN-NEXT: %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
64 ---
65 name: no-fold-copy-readfirstlane-physreg0
66 tracksRegLiveness: true
67 body:             |
68   bb.0:
69     liveins: $sgpr10
70     %0:vgpr_32 = COPY $sgpr10
71     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
73 ...
75 # GCN-LABEL: name: no-fold-copy-readfirstlane-physreg1{{$}}
76 # GCN: $vgpr0 = COPY $sgpr10
77 # GCN-NEXT: %0:sreg_32_xm0 = V_READFIRSTLANE_B32 $vgpr0, implicit $exec
78 ---
79 name: no-fold-copy-readfirstlane-physreg1
80 tracksRegLiveness: true
81 body:             |
82   bb.0:
83     liveins: $sgpr10
84     $vgpr0 = COPY $sgpr10
85     %0:sreg_32_xm0 = V_READFIRSTLANE_B32 $vgpr0, implicit $exec
87 ...
89 # GCN-LABEL: name: no-fold-imm-readfirstlane-physreg{{$}}
90 # GCN: $vgpr0 = V_MOV_B32_e32 123, implicit $exec
91 # GCN-NEXT: V_READFIRSTLANE_B32 $vgpr0, implicit $exec
93 ---
94 name: no-fold-imm-readfirstlane-physreg
95 tracksRegLiveness: true
96 body:             |
97   bb.0:
98     $vgpr0 = V_MOV_B32_e32 123, implicit $exec
99     %0:sreg_32_xm0 = V_READFIRSTLANE_B32 $vgpr0, implicit $exec
102 # TODO: This could be folded, if the search for exec modifications was
103 # smarter.
105 # GCN-LABEL: name: fold-imm-readfirstlane-cross-block{{$}}
106 # GCN: V_MOV_B32
107 # GCN: V_READFIRSTLANE_B32
109 name: fold-imm-readfirstlane-cross-block
110 tracksRegLiveness: true
111 body:             |
112   bb.0:
113     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
115   bb.1:
116     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
119 # TODO: This could be folded, if the search for exec modifications was
120 # smarter.
122 # GCN-LABEL: name: fold-copy-readfirstlane-cross-block{{$}}
123 # GCN: V_MOV_B32
124 # GCN: V_READFIRSTLANE_B32
126 name: fold-copy-readfirstlane-cross-block
127 tracksRegLiveness: true
128 body:             |
129   bb.0:
130     liveins: $sgpr12
131     %0:sreg_32_xm0 = COPY $sgpr12
132     %1:vgpr_32 = V_MOV_B32_e32 %0, implicit $exec
134   bb.1:
135     %2:sreg_32_xm0 = V_READFIRSTLANE_B32 %1, implicit $exec
138 # GCN-LABEL: name: fold-copy-readfirstlane-cross-block-exec-def{{$}}
139 # GCN: V_MOV_B32
140 # GCN: $exec = S_MOV_B64_term
141 # GCN: V_READFIRSTLANE_B32
143 name: fold-copy-readfirstlane-cross-block-exec-def
144 tracksRegLiveness: true
145 body:             |
146   bb.0:
147     liveins: $sgpr10_sgpr11, $sgpr12
148     %0:sreg_32_xm0 = COPY $sgpr12
149     %1:vgpr_32 = V_MOV_B32_e32 %0, implicit $exec
150     $exec = S_MOV_B64_term $sgpr10_sgpr11
152   bb.1:
153     %2:sreg_32_xm0 = V_READFIRSTLANE_B32 %1, implicit $exec
156 # GCN-LABEL: name: fold-copy-readfirstlane-same-block-exec-def{{$}}
157 # GCN: COPY
158 # GCN-NEXT: %1:vgpr_32 = COPY %0
159 # GCN-NEXT: $exec = S_MOV_B64
160 # GCN-NEXT: V_READFIRSTLANE_B32
162 name: fold-copy-readfirstlane-same-block-exec-def
163 tracksRegLiveness: true
164 body:             |
165   bb.0:
166     liveins: $sgpr10_sgpr11, $sgpr12
167     %0:sreg_32_xm0 = COPY $sgpr12
168     %1:vgpr_32 = COPY %0, implicit $exec
169     $exec = S_MOV_B64 $sgpr10_sgpr11
170     %2:sreg_32_xm0 = V_READFIRSTLANE_B32 %1, implicit $exec
174 # GCN-LABEL: name: fold-imm-readfirstlane-cross-block-exec-def{{$}}
175 # GCN: V_MOV_B32
176 # GCN: $exec = S_MOV_B64
177 # GCN: V_READFIRSTLANE_B32
180 name: fold-imm-readfirstlane-cross-block-exec-def
181 tracksRegLiveness: true
182 body:             |
183   bb.0:
184     liveins: $sgpr10_sgpr11, $sgpr12_sgpr13
185     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
186     $exec = S_MOV_B64_term $sgpr10_sgpr11
188   bb.1:
189     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
192 # GCN-LABEL: name: fold-imm-readfirstlane-same-block-exec-def{{$}}
193 # GCN: V_MOV_B32
194 # GCN-NEXT: $exec = S_MOV_B64
195 # GCN-NEXT: V_READFIRSTLANE_B32
197 name: fold-imm-readfirstlane-same-block-exec-def
198 tracksRegLiveness: true
199 body:             |
200   bb.0:
201     liveins: $sgpr10_sgpr11
202     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
203     $exec = S_MOV_B64 $sgpr10_sgpr11
204     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
208 # GCN-LABEL: name: fold-sgpr-copy-readfirstlane-same-block-exec-def{{$}}
209 # GCN: COPY
210 # GCN-NEXT: $exec = S_MOV_B64
211 # GCN-NEXT: V_READFIRSTLANE_B32
213 name: fold-sgpr-copy-readfirstlane-same-block-exec-def
214 tracksRegLiveness: true
215 body:             |
216   bb.0:
217     liveins: $sgpr10_sgpr11, $sgpr12
218     %0:vgpr_32 = COPY $sgpr12
219     $exec = S_MOV_B64 $sgpr10_sgpr11
220     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
223 # GCN-LABEL: name: fold-imm-readfirstlane-user{{$}}
224 # GCN: %3:sreg_32_xm0 = S_MOV_B32 123
226 name: fold-imm-readfirstlane-user
227 tracksRegLiveness: true
228 body:             |
229   bb.0:
230     liveins: $vgpr0, $sgpr0_sgpr1
231     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
232     %1:sreg_32_xm0 = V_READFIRSTLANE_B32 %0, implicit $exec
233     %2:sreg_32_xm0 = COPY %1
234     %3:sreg_32_xm0 = COPY %2
235     S_ENDPGM 0, implicit %3
238 # GCN-LABEL: name: fold-imm-readlane{{$}}
239 # GCN: %1:sreg_32_xm0 = S_MOV_B32 123
241 name: fold-imm-readlane
242 tracksRegLiveness: true
243 body:             |
244   bb.0:
245     liveins: $vgpr0, $sgpr0_sgpr1
246     %0:vgpr_32 = V_MOV_B32_e32 123, implicit $exec
247     %1:sreg_32_xm0 = V_READLANE_B32 %0, 0, implicit $exec
248     S_NOP 0, implicit %1
251 # GCN-LABEL: name: fold-imm-readlane-src1{{$}}
252 # GCN: %0:vgpr_32 = COPY $vgpr0
253 # GCN: V_READLANE_B32 %0, 12, implicit $exec
255 name: fold-imm-readlane-src1
256 tracksRegLiveness: true
257 body:             |
258   bb.0:
259     liveins: $vgpr0
260     %0:vgpr_32 = COPY $vgpr0
261     %1:sreg_32_xm0 = S_MOV_B32 12
262     %2:sreg_32_xm0 = V_READLANE_B32 %0, %1, implicit $exec
265 # Constant for subreg0
266 # GCN-LABEL: name: fold-imm-readfirstlane-regsequence0{{$}}
268 # GCN: %0:vgpr_32 = COPY $vgpr0
269 # GCN-NEXT: %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
270 # GCN-NEXT: %2:vreg_64 = REG_SEQUENCE %0, %subreg.sub0, killed %1, %subreg.sub1
271 # GCN-NEXT: %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0, implicit $exec
272 # GCN-NEXT: %4:sgpr_32 = S_MOV_B32 0
274 name: fold-imm-readfirstlane-regsequence0
275 tracksRegLiveness: true
276 body:             |
277   bb.0:
278     liveins: $vgpr0
279     %0:vgpr_32 = COPY $vgpr0
280     %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
281     %2:vreg_64 = REG_SEQUENCE %0:vgpr_32, %subreg.sub0, killed %1:vgpr_32, %subreg.sub1
282     %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0:vreg_64, implicit $exec
283     %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1:vreg_64, implicit $exec
284     S_NOP 0, implicit %3, implicit %4
287 # Constant for subreg1
288 # GCN-LABEL: name: fold-imm-readfirstlane-regsequence1{{$}}
289 # GCN: %0:vgpr_32 = COPY $vgpr0
290 # GCN-NEXT: %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
291 # GCN-NEXT: %2:vreg_64 = REG_SEQUENCE %1, %subreg.sub0, killed %0, %subreg.sub1
292 # GCN-NEXT: %3:sgpr_32 = S_MOV_B32 0
293 # GCN-NEXT: %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1, implicit $exec
296 name: fold-imm-readfirstlane-regsequence1
297 tracksRegLiveness: true
298 body:             |
299   bb.0:
300     liveins: $vgpr0
301     %0:vgpr_32 = COPY $vgpr0
302     %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
303     %2:vreg_64 = REG_SEQUENCE %1:vgpr_32, %subreg.sub0, killed %0:vgpr_32, %subreg.sub1
304     %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0:vreg_64, implicit $exec
305     %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1:vreg_64, implicit $exec
306     S_NOP 0, implicit %3, implicit %4
309 # Different constant regs for each subreg
310 # GCN-LABEL: name: fold-imm-readfirstlane-regsequence2{{$}}
311 # GCN: %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
312 # GCN-NEXT: %1:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
313 # GCN-NEXT: %2:vreg_64 = REG_SEQUENCE %0, %subreg.sub0, killed %1, %subreg.sub1
314 # GCN-NEXT: %3:sgpr_32 = S_MOV_B32 0
315 # GCN-NEXT: %4:sgpr_32 = S_MOV_B32 1
317 name: fold-imm-readfirstlane-regsequence2
318 tracksRegLiveness: true
319 body:             |
320   bb.0:
321     %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
322     %1:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
323     %2:vreg_64 = REG_SEQUENCE %0:vgpr_32, %subreg.sub0, killed %1:vgpr_32, %subreg.sub1
324     %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0:vreg_64, implicit $exec
325     %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1:vreg_64, implicit $exec
326     S_NOP 0, implicit %3, implicit %4
329 # Same constant reg for each subreg, so there are multiple constant uses
330 # GCN-LABEL: name: fold-imm-readfirstlane-regsequence3{{$}}
331 # GCN: %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
332 # GCN-NEXT: %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
333 # GCN-NEXT: %2:vreg_64 = REG_SEQUENCE %0, %subreg.sub0, killed %1, %subreg.sub1
334 # GCN-NEXT: %3:sgpr_32 = S_MOV_B32 0
335 # GCN-NEXT: %4:sgpr_32 = S_MOV_B32 0
337 name: fold-imm-readfirstlane-regsequence3
338 tracksRegLiveness: true
339 body:             |
340   bb.0:
341     %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
342     %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
343     %2:vreg_64 = REG_SEQUENCE %0:vgpr_32, %subreg.sub0, killed %1:vgpr_32, %subreg.sub1
344     %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0:vreg_64, implicit $exec
345     %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1:vreg_64, implicit $exec
346     S_NOP 0, implicit %3, implicit %4
349 # FIXME: This should fold
350 # GCN-LABEL: name: fold-copy-readfirstlane-regsequence0{{$}}
351 # GCN: %0:vgpr_32 = COPY $sgpr10
352 # GCN-NEXT: %1:vgpr_32 = COPY $sgpr11
353 # GCN-NEXT: %2:vreg_64 = REG_SEQUENCE %0, %subreg.sub0, killed %1, %subreg.sub1
354 # GCN-NEXT: %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0, implicit $exec
355 # GCN-NEXT: %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1, implicit $exec
357 name: fold-copy-readfirstlane-regsequence0
358 tracksRegLiveness: true
359 body:             |
360   bb.0:
361     liveins: $sgpr10, $sgpr11
362     %0:vgpr_32 = COPY $sgpr10
363     %1:vgpr_32 = COPY $sgpr11
364     %2:vreg_64 = REG_SEQUENCE %0:vgpr_32, %subreg.sub0, killed %1:vgpr_32, %subreg.sub1
365     %3:sgpr_32 = V_READFIRSTLANE_B32 %2.sub0:vreg_64, implicit $exec
366     %4:sgpr_32 = V_READFIRSTLANE_B32 %2.sub1:vreg_64, implicit $exec
369 # GCN-LABEL: name: fold-copy-readfirstlane-regsequence1{{$}}
370 # GCN: %0:sreg_32_xm0 = COPY $sgpr10
371 # GCN-NEXT: %1:sreg_32_xm0 = COPY $sgpr11
372 # GCN-NEXT: %2:vgpr_32 = COPY %0
373 # GCN-NEXT: %3:vgpr_32 = COPY %1
374 # GCN-NEXT: %4:vreg_64 = REG_SEQUENCE %2, %subreg.sub0, killed %3, %subreg.sub1
375 # GCN-NEXT: %5:sgpr_32 = V_READFIRSTLANE_B32 %4.sub0, implicit $exec
376 # GCN-NEXT: %6:sgpr_32 = V_READFIRSTLANE_B32 %4.sub1, implicit $exec
378 name: fold-copy-readfirstlane-regsequence1
379 tracksRegLiveness: true
380 body:             |
381   bb.0:
382     liveins: $sgpr10, $sgpr11
383     %0:sreg_32_xm0 = COPY $sgpr10
384     %1:sreg_32_xm0 = COPY $sgpr11
385     %2:vgpr_32 = COPY %0
386     %3:vgpr_32 = COPY %1
387     %4:vreg_64 = REG_SEQUENCE %2:vgpr_32, %subreg.sub0, killed %3:vgpr_32, %subreg.sub1
388     %5:sgpr_32 = V_READFIRSTLANE_B32 %4.sub0:vreg_64, implicit $exec
389     %6:sgpr_32 = V_READFIRSTLANE_B32 %4.sub1:vreg_64, implicit $exec