[InstCombine] Signed saturation patterns
[llvm-complete.git] / test / CodeGen / AMDGPU / GlobalISel / inst-select-copy.mir
blob53fbcb4cd4bcc2ed54f8724ebde88fdb3d067ff6
1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=hawaii -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=WAVE64 %s
3 # RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize32,-wavefrontsize64  -run-pass=instruction-select -verify-machineinstrs -o - %s | FileCheck -check-prefix=WAVE32 %s
5 ---
7 name:            copy
8 legalized:       true
9 regBankSelected: true
12 body: |
13   bb.0:
14     liveins: $sgpr2_sgpr3
16     ; WAVE64-LABEL: name: copy
17     ; WAVE64: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr2_sgpr3
18     ; WAVE64: [[COPY1:%[0-9]+]]:vreg_64 = COPY [[COPY]]
19     ; WAVE64: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
20     ; WAVE64: FLAT_STORE_DWORD [[COPY1]], [[DEF]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
21     ; WAVE32-LABEL: name: copy
22     ; WAVE32: $vcc_hi = IMPLICIT_DEF
23     ; WAVE32: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr2_sgpr3
24     ; WAVE32: [[COPY1:%[0-9]+]]:vreg_64 = COPY [[COPY]]
25     ; WAVE32: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
26     ; WAVE32: GLOBAL_STORE_DWORD [[COPY1]], [[DEF]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
27     %0:sgpr(p1) = COPY $sgpr2_sgpr3
28     %1:vgpr(p1) = COPY %0
29     %2:vgpr(s32) = G_IMPLICIT_DEF
30     G_STORE %2, %1 :: (store 4, addrspace 1)
31 ...
32 ---
34 name:            copy_vcc_bank_scc_bank
35 legalized:       true
36 regBankSelected: true
38 body: |
39   bb.0:
40     liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
42     ; WAVE64-LABEL: name: copy_vcc_bank_scc_bank
43     ; WAVE64: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
44     ; WAVE64: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
45     ; WAVE64: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
46     ; WAVE64: [[COPY3:%[0-9]+]]:sgpr_32 = COPY $scc
47     ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[COPY3]], implicit $exec
48     ; WAVE64: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
49     ; WAVE64: FLAT_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
50     ; WAVE32-LABEL: name: copy_vcc_bank_scc_bank
51     ; WAVE32: $vcc_hi = IMPLICIT_DEF
52     ; WAVE32: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
53     ; WAVE32: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
54     ; WAVE32: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
55     ; WAVE32: [[COPY3:%[0-9]+]]:sgpr_32 = COPY $scc
56     ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32_xm0_xexec = V_CMP_NE_U32_e64 0, [[COPY3]], implicit $exec
57     ; WAVE32: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
58     ; WAVE32: GLOBAL_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
59     %0:vgpr(p1) = COPY $vgpr0_vgpr1
60     %1:vgpr(s32) = COPY $vgpr2
61     %2:vgpr(s32) = COPY $vgpr3
62     %3:scc(s1) = COPY $scc
63     %4:vcc(s1) = COPY %3
64     %5:vgpr(s32) = G_SELECT %4, %1, %2
65     G_STORE %5, %0 :: (store 4, addrspace 1)
66 ...
67 ---
69 name:            copy_vcc_bank_scc_bank_2_uses
70 legalized:       true
71 regBankSelected: true
73 body: |
74   bb.0:
75     liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
77     ; WAVE64-LABEL: name: copy_vcc_bank_scc_bank_2_uses
78     ; WAVE64: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
79     ; WAVE64: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
80     ; WAVE64: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
81     ; WAVE64: [[COPY3:%[0-9]+]]:sgpr_32 = COPY $scc
82     ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[COPY3]], implicit $exec
83     ; WAVE64: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
84     ; WAVE64: [[V_CMP_NE_U32_e64_1:%[0-9]+]]:sreg_64_xexec = V_CMP_NE_U32_e64 0, [[COPY3]], implicit $exec
85     ; WAVE64: [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_CNDMASK_B32_e64_]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_1]], implicit $exec
86     ; WAVE64: FLAT_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_1]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
87     ; WAVE32-LABEL: name: copy_vcc_bank_scc_bank_2_uses
88     ; WAVE32: $vcc_hi = IMPLICIT_DEF
89     ; WAVE32: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
90     ; WAVE32: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
91     ; WAVE32: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
92     ; WAVE32: [[COPY3:%[0-9]+]]:sgpr_32 = COPY $scc
93     ; WAVE32: [[COPY4:%[0-9]+]]:sreg_32_xm0_xexec = COPY [[COPY3]]
94     ; WAVE32: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[COPY4]], implicit $exec
95     ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32_xm0_xexec = V_CMP_NE_U32_e64 0, [[COPY3]], implicit $exec
96     ; WAVE32: [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_CNDMASK_B32_e64_]], 0, [[COPY1]], [[V_CMP_NE_U32_e64_]], implicit $exec
97     ; WAVE32: GLOBAL_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_1]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
98     %0:vgpr(p1) = COPY $vgpr0_vgpr1
99     %1:vgpr(s32) = COPY $vgpr2
100     %2:vgpr(s32) = COPY $vgpr3
101     %3:scc(s1) = COPY $scc
102     %4:vcc(s1) = COPY %3
103     %5:vgpr(s32) = G_SELECT %4, %1, %2
104     %6:vcc(s1) = COPY %3
105     %7:vgpr(s32) = G_SELECT %6, %1, %5
106     G_STORE %7, %0 :: (store 4, addrspace 1)
111 name:            copy_vcc_bank_scc_physreg
112 legalized:       true
113 regBankSelected: true
115 body: |
116   bb.0:
117     liveins: $vgpr0_vgpr1, $vgpr2, $vgpr3, $scc
119     ; WAVE64-LABEL: name: copy_vcc_bank_scc_physreg
120     ; WAVE64: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
121     ; WAVE64: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
122     ; WAVE64: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
123     ; WAVE64: [[COPY3:%[0-9]+]]:sreg_64_xexec = COPY $scc
124     ; WAVE64: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[COPY3]], implicit $exec
125     ; WAVE64: FLAT_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4, addrspace 1)
126     ; WAVE32-LABEL: name: copy_vcc_bank_scc_physreg
127     ; WAVE32: $vcc_hi = IMPLICIT_DEF
128     ; WAVE32: [[COPY:%[0-9]+]]:vreg_64 = COPY $vgpr0_vgpr1
129     ; WAVE32: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr2
130     ; WAVE32: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr3
131     ; WAVE32: [[COPY3:%[0-9]+]]:sreg_32_xm0_xexec = COPY $scc
132     ; WAVE32: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY2]], 0, [[COPY1]], [[COPY3]], implicit $exec
133     ; WAVE32: GLOBAL_STORE_DWORD [[COPY]], [[V_CNDMASK_B32_e64_]], 0, 0, 0, 0, implicit $exec :: (store 4, addrspace 1)
134     %0:vgpr(p1) = COPY $vgpr0_vgpr1
135     %1:vgpr(s32) = COPY $vgpr2
136     %2:vgpr(s32) = COPY $vgpr3
137     %3:vcc(s1) = COPY $scc
138     %5:vgpr(s32) = G_SELECT %3, %1, %2
139     G_STORE %5, %0 :: (store 4, addrspace 1)
143 name:            copy_sgpr_no_type
144 legalized:       true
145 regBankSelected: true
148 body: |
149   bb.0:
150     liveins: $sgpr0
151     ; WAVE64-LABEL: name: copy_sgpr_no_type
152     ; WAVE64: [[COPY:%[0-9]+]]:sreg_32_xm0 = COPY $sgpr0
153     ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
154     ; WAVE32-LABEL: name: copy_sgpr_no_type
155     ; WAVE32: $vcc_hi = IMPLICIT_DEF
156     ; WAVE32: [[COPY:%[0-9]+]]:sreg_32_xm0 = COPY $sgpr0
157     ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
158     %0:sreg_32_xm0 = COPY $sgpr0
159     %1:sreg_32_xm0 = COPY %0
160     S_ENDPGM 0, implicit %1
166 name:            copy_vgpr_no_type
167 legalized:       true
168 regBankSelected: true
171 body: |
172   bb.0:
173     liveins: $vgpr0
174     ; WAVE64-LABEL: name: copy_vgpr_no_type
175     ; WAVE64: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
176     ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
177     ; WAVE32-LABEL: name: copy_vgpr_no_type
178     ; WAVE32: $vcc_hi = IMPLICIT_DEF
179     ; WAVE32: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
180     ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
181     %0:vgpr_32 = COPY $vgpr0
182     %1:vgpr_32 = COPY %0
183     S_ENDPGM 0, implicit %1
189 name:            copy_maybe_vcc
190 legalized:       true
191 regBankSelected: true
194 body: |
195   bb.0:
196     liveins: $sgpr0_sgpr1
197     ; WAVE64-LABEL: name: copy_maybe_vcc
198     ; WAVE64: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr0_sgpr1
199     ; WAVE64: S_ENDPGM 0, implicit [[COPY]]
200     ; WAVE32-LABEL: name: copy_maybe_vcc
201     ; WAVE32: $vcc_hi = IMPLICIT_DEF
202     ; WAVE32: [[COPY:%[0-9]+]]:sreg_64_xexec = COPY $sgpr0_sgpr1
203     ; WAVE32: S_ENDPGM 0, implicit [[COPY]]
204     %0:sreg_64_xexec = COPY $sgpr0_sgpr1
205     %1:sreg_64_xexec  = COPY %0
206     S_ENDPGM 0, implicit %1
212 name:            copy_sgpr_s1_to_vcc
213 legalized:       true
214 regBankSelected: true
217 body: |
218   ; WAVE64-LABEL: name: copy_sgpr_s1_to_vcc
219   ; WAVE64: bb.0:
220   ; WAVE64:   successors: %bb.1(0x80000000)
221   ; WAVE64:   [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
222   ; WAVE64:   [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
223   ; WAVE64:   $vcc = COPY [[V_CMP_NE_U32_e64_]]
224   ; WAVE64:   S_CBRANCH_VCCNZ %bb.1, implicit $vcc
225   ; WAVE64: bb.1:
226   ; WAVE32-LABEL: name: copy_sgpr_s1_to_vcc
227   ; WAVE32: bb.0:
228   ; WAVE32:   successors: %bb.1(0x80000000)
229   ; WAVE32:   $vcc_hi = IMPLICIT_DEF
230   ; WAVE32:   [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
231   ; WAVE32:   [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
232   ; WAVE32:   $vcc_lo = COPY [[V_CMP_NE_U32_e64_]]
233   ; WAVE32:   S_CBRANCH_VCCNZ %bb.1, implicit $vcc_lo
234   ; WAVE32: bb.1:
235   bb.0:
236     liveins: $sgpr0_sgpr1
237     %0:sgpr(s32) = COPY $sgpr0
238     %1:sgpr(s1) = G_TRUNC %0
239     %2:vcc(s1) = COPY %1
240     G_BRCOND %2, %bb.1
242   bb.1:
248 name:            copy_sgpr_s1_to_vcc_constrain
249 legalized:       true
250 regBankSelected: true
253 body: |
254   bb.0:
255     liveins: $sgpr0_sgpr1
256     ; WAVE64-LABEL: name: copy_sgpr_s1_to_vcc_constrain
257     ; WAVE64: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
258     ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
259     ; WAVE64: S_ENDPGM 0, implicit [[V_CMP_NE_U32_e64_]]
260     ; WAVE32-LABEL: name: copy_sgpr_s1_to_vcc_constrain
261     ; WAVE32: $vcc_hi = IMPLICIT_DEF
262     ; WAVE32: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
263     ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
264     ; WAVE32: S_ENDPGM 0, implicit [[V_CMP_NE_U32_e64_]]
265     %0:sgpr(s32) = COPY $sgpr0
266     %1:sgpr(s1) = G_TRUNC %0
267     %2:vcc(s1) = COPY %1
268     S_ENDPGM 0, implicit %2
274 name:            copy_s1_vcc_to_vcc
275 legalized:       true
276 regBankSelected: true
279 body: |
280   bb.0:
281     liveins: $sgpr0_sgpr1
283     ; WAVE64-LABEL: name: copy_s1_vcc_to_vcc
284     ; WAVE64: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
285     ; WAVE64: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_64 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
286     ; WAVE64: [[COPY1:%[0-9]+]]:sreg_64_xexec = COPY [[V_CMP_NE_U32_e64_]]
287     ; WAVE64: S_ENDPGM 0, implicit [[COPY1]]
288     ; WAVE32-LABEL: name: copy_s1_vcc_to_vcc
289     ; WAVE32: $vcc_hi = IMPLICIT_DEF
290     ; WAVE32: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr0
291     ; WAVE32: [[V_CMP_NE_U32_e64_:%[0-9]+]]:sreg_32 = V_CMP_NE_U32_e64 0, [[COPY]], implicit $exec
292     ; WAVE32: [[COPY1:%[0-9]+]]:sreg_32_xm0_xexec = COPY [[V_CMP_NE_U32_e64_]]
293     ; WAVE32: S_ENDPGM 0, implicit [[COPY1]]
294     %0:sgpr(s32) = COPY $sgpr0
295     %1:sgpr(s1) = G_TRUNC %0
296     %2:vcc(s1) = COPY %1
297     %3:vcc(s1) = COPY %2
298     S_ENDPGM 0, implicit %3
304 name:            copy_s1_vcc_to_vcc_undef
305 legalized:       true
306 regBankSelected: true
309 body: |
310   bb.0:
311     liveins: $sgpr0_sgpr1
313     ; WAVE64-LABEL: name: copy_s1_vcc_to_vcc_undef
314     ; WAVE64: S_ENDPGM 0, implicit %1:sreg_64_xexec
315     ; WAVE32-LABEL: name: copy_s1_vcc_to_vcc_undef
316     ; WAVE32: $vcc_hi = IMPLICIT_DEF
317     ; WAVE32: S_ENDPGM 0, implicit %1:sreg_32_xm0_xexec
318     %1:vcc(s1) = COPY undef  %0:vcc(s1)
319     S_ENDPGM 0, implicit %1