1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx940 -verify-machineinstrs -run-pass peephole-opt -o - %s | FileCheck -check-prefix=GCN %s
5 name: fold_simm_virtual
9 ; GCN-LABEL: name: fold_simm_virtual
10 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
11 ; GCN-NEXT: SI_RETURN_TO_EPILOG
12 %0:sreg_32 = S_MOV_B32 0
13 %1:sreg_32 = COPY killed %0
19 name: fold_simm_physical
23 ; GCN-LABEL: name: fold_simm_physical
24 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
25 ; GCN-NEXT: $sgpr1 = S_MOV_B32 0
26 ; GCN-NEXT: SI_RETURN_TO_EPILOG
27 %0:sreg_32 = S_MOV_B32 0
28 $sgpr1 = COPY killed %0
34 name: dont_fold_simm_scc
38 ; GCN-LABEL: name: dont_fold_simm_scc
39 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
40 ; GCN-NEXT: $scc = COPY killed [[S_MOV_B32_]]
41 ; GCN-NEXT: SI_RETURN_TO_EPILOG
42 %0:sreg_32 = S_MOV_B32 0
49 name: fold_simm_16_sub_to_lo
53 ; GCN-LABEL: name: fold_simm_16_sub_to_lo
54 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2048
55 ; GCN-NEXT: [[COPY:%[0-9]+]]:sgpr_lo16 = COPY killed [[S_MOV_B32_]].lo16
56 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[COPY]]
57 %0:sreg_32 = S_MOV_B32 2048
58 %1:sgpr_lo16 = COPY killed %0.lo16
59 SI_RETURN_TO_EPILOG %1
64 name: fold_simm_16_sub_to_phys
68 ; GCN-LABEL: name: fold_simm_16_sub_to_phys
69 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2048
70 ; GCN-NEXT: $sgpr0 = S_MOV_B32 2048
71 ; GCN-NEXT: SI_RETURN_TO_EPILOG $sgpr0_lo16
72 %0:sreg_32 = S_MOV_B32 2048
73 $sgpr0_lo16 = COPY killed %0.lo16
74 SI_RETURN_TO_EPILOG $sgpr0_lo16
79 name: fold_aimm_16_sub_to_phys
83 ; GCN-LABEL: name: fold_aimm_16_sub_to_phys
84 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0
85 ; GCN-NEXT: $agpr0 = V_ACCVGPR_WRITE_B32_e64 0, implicit $exec
86 ; GCN-NEXT: SI_RETURN_TO_EPILOG $agpr0_lo16
87 %0:sreg_32 = S_MOV_B32 0
88 $agpr0_lo16 = COPY killed %0.lo16
89 SI_RETURN_TO_EPILOG $agpr0_lo16
94 name: fold_vimm_16_sub_to_lo
98 ; GCN-LABEL: name: fold_vimm_16_sub_to_lo
99 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2048
100 ; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_16 = COPY killed [[S_MOV_B32_]].lo16
101 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[COPY]]
102 %0:sreg_32 = S_MOV_B32 2048
103 %1:vgpr_16 = COPY killed %0.lo16
104 SI_RETURN_TO_EPILOG %1
109 name: fold_vimm_16_sub_to_phys
113 ; GCN-LABEL: name: fold_vimm_16_sub_to_phys
114 ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 2048
115 ; GCN-NEXT: $vgpr0_lo16 = COPY killed [[S_MOV_B32_]].lo16
116 ; GCN-NEXT: SI_RETURN_TO_EPILOG $vgpr0_lo16
117 %0:sreg_32 = S_MOV_B32 2048
118 $vgpr0_lo16 = COPY killed %0.lo16
119 SI_RETURN_TO_EPILOG $vgpr0_lo16
124 name: fold_sreg_64_sub0_to_vgpr_32
128 ; GCN-LABEL: name: fold_sreg_64_sub0_to_vgpr_32
129 ; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
130 ; GCN-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 -1412567312, implicit $exec
131 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_MOV_B32_e32_]]
132 %0:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
133 %1:vgpr_32 = COPY killed %0.sub0
134 SI_RETURN_TO_EPILOG %1
139 name: fold_sreg_64_sub1_to_vgpr_32
143 ; GCN-LABEL: name: fold_sreg_64_sub1_to_vgpr_32
144 ; GCN: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1311768467750121200
145 ; GCN-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 305419896, implicit $exec
146 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_MOV_B32_e32_]]
147 %0:sreg_64 = S_MOV_B64 1311768467750121200
148 %1:vgpr_32 = COPY killed %0.sub1
149 SI_RETURN_TO_EPILOG %1
154 name: fold_vreg_64_sub1_to_vgpr_32
158 ; GCN-LABEL: name: fold_vreg_64_sub1_to_vgpr_32
159 ; GCN: [[V_MOV_B:%[0-9]+]]:vreg_64_align2 = V_MOV_B64_PSEUDO 1311768467750121200, implicit $exec
160 ; GCN-NEXT: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 305419896, implicit $exec
161 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_MOV_B32_e32_]]
162 %0:vreg_64_align2 = V_MOV_B64_PSEUDO 1311768467750121200, implicit $exec
163 %1:vgpr_32 = COPY killed %0.sub1
164 SI_RETURN_TO_EPILOG %1
169 name: fold_sreg_64_to_vreg_64
173 ; GCN-LABEL: name: fold_sreg_64_to_vreg_64
174 ; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
175 ; GCN-NEXT: [[V_MOV_B:%[0-9]+]]:vreg_64_align2 = V_MOV_B64_PSEUDO 1311768467750121200, implicit $exec
176 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_MOV_B]]
177 %0:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
178 %1:vreg_64_align2 = COPY killed %0
179 SI_RETURN_TO_EPILOG %1
184 name: fold_sreg_64_to_sreg_64
188 ; GCN-LABEL: name: fold_sreg_64_to_sreg_64
189 ; GCN: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1311768467750121200
190 ; GCN-NEXT: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
191 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[S_MOV_B]]
192 %0:sreg_64 = S_MOV_B64 1311768467750121200
193 %1:sreg_64 = COPY killed %0
194 SI_RETURN_TO_EPILOG %1
199 name: fold_sreg_64_lo16_to_sgpr_lo16
203 ; GCN-LABEL: name: fold_sreg_64_lo16_to_sgpr_lo16
204 ; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
205 ; GCN-NEXT: $sgpr0 = S_MOV_B32 1
206 ; GCN-NEXT: SI_RETURN_TO_EPILOG $sgpr0_lo16
207 %0:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
208 $sgpr0_lo16 = COPY killed %0.lo16
209 SI_RETURN_TO_EPILOG $sgpr0_lo16
214 name: fold_sreg_64_hi16_to_sgpr_lo16
218 ; GCN-LABEL: name: fold_sreg_64_hi16_to_sgpr_lo16
219 ; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
220 ; GCN-NEXT: $sgpr0 = S_MOV_B32 2
221 ; GCN-NEXT: SI_RETURN_TO_EPILOG $sgpr0_lo16
222 %0:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
223 $sgpr0_lo16 = COPY killed %0.hi16
224 SI_RETURN_TO_EPILOG $sgpr0_lo16
229 name: fold_sreg_64_sub1_lo16_to_sgpr_lo16
233 ; GCN-LABEL: name: fold_sreg_64_sub1_lo16_to_sgpr_lo16
234 ; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
235 ; GCN-NEXT: $sgpr0 = S_MOV_B32 3
236 ; GCN-NEXT: SI_RETURN_TO_EPILOG $sgpr0_lo16
237 %0:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
238 $sgpr0_lo16 = COPY killed %0.sub1_lo16
239 SI_RETURN_TO_EPILOG $sgpr0_lo16
244 name: fold_sreg_64_sub1_hi16_to_sgpr_lo16
248 ; GCN-LABEL: name: fold_sreg_64_sub1_hi16_to_sgpr_lo16
249 ; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
250 ; GCN-NEXT: $sgpr0 = S_MOV_B32 4
251 ; GCN-NEXT: SI_RETURN_TO_EPILOG $sgpr0_lo16
252 %0:sreg_64 = S_MOV_B64_IMM_PSEUDO 1125912791875585
253 $sgpr0_lo16 = COPY killed %0.sub1_hi16
254 SI_RETURN_TO_EPILOG $sgpr0_lo16
259 name: fmac_sreg_64_sub0_src0_to_fmamk
260 tracksRegLiveness: true
264 ; GCN-LABEL: name: fmac_sreg_64_sub0_src0_to_fmamk
265 ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
266 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
267 ; GCN-NEXT: [[V_FMAMK_F32_:%[0-9]+]]:vgpr_32 = V_FMAMK_F32 [[DEF]], 2882399984, [[DEF1]], implicit $mode, implicit $exec
268 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_FMAMK_F32_]]
269 %0:vgpr_32 = IMPLICIT_DEF
270 %1:vgpr_32 = IMPLICIT_DEF
271 %2:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
272 %3:vgpr_32 = V_FMAC_F32_e64 0, %2.sub0, 0, %0, 0, %1, 0, 0, implicit $mode, implicit $exec
273 SI_RETURN_TO_EPILOG %3
277 name: fmac_sreg_64_sub1_src0_to_fmamk
278 tracksRegLiveness: true
282 ; GCN-LABEL: name: fmac_sreg_64_sub1_src0_to_fmamk
283 ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
284 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
285 ; GCN-NEXT: [[V_FMAMK_F32_:%[0-9]+]]:vgpr_32 = V_FMAMK_F32 [[DEF]], 305419896, [[DEF1]], implicit $mode, implicit $exec
286 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_FMAMK_F32_]]
287 %0:vgpr_32 = IMPLICIT_DEF
288 %1:vgpr_32 = IMPLICIT_DEF
289 %2:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
290 %3:vgpr_32 = V_FMAC_F32_e64 0, %2.sub1, 0, %0, 0, %1, 0, 0, implicit $mode, implicit $exec
291 SI_RETURN_TO_EPILOG %3
295 name: fmac_sreg_64_sub1_src1_to_fmaak
296 tracksRegLiveness: true
300 ; GCN-LABEL: name: fmac_sreg_64_sub1_src1_to_fmaak
301 ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
302 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
303 ; GCN-NEXT: [[V_FMAMK_F32_:%[0-9]+]]:vgpr_32 = V_FMAMK_F32 [[DEF]], 305419896, [[DEF1]], implicit $mode, implicit $exec
304 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_FMAMK_F32_]]
305 %0:vgpr_32 = IMPLICIT_DEF
306 %1:vgpr_32 = IMPLICIT_DEF
307 %2:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
308 %3:vgpr_32 = V_FMAC_F32_e64 0, %0, 0, %2.sub1, 0, %1, 0, 0, implicit $mode, implicit $exec
309 SI_RETURN_TO_EPILOG %3
313 name: fma_sreg_64_sub0_to_fmaak
314 tracksRegLiveness: true
318 ; GCN-LABEL: name: fma_sreg_64_sub0_to_fmaak
319 ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
320 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
321 ; GCN-NEXT: [[V_FMAAK_F32_:%[0-9]+]]:vgpr_32 = V_FMAAK_F32 [[DEF]], [[DEF1]], 2882399984, implicit $mode, implicit $exec
322 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_FMAAK_F32_]]
323 %0:vgpr_32 = IMPLICIT_DEF
324 %1:vgpr_32 = IMPLICIT_DEF
325 %2:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
326 %3:vgpr_32 = V_FMA_F32_e64 0, %0, 0, %1, 0, %2.sub0, 0, 0, implicit $mode, implicit $exec
327 SI_RETURN_TO_EPILOG %3
331 name: fma_sreg_64_sub1_to_fmaak
332 tracksRegLiveness: true
336 ; GCN-LABEL: name: fma_sreg_64_sub1_to_fmaak
337 ; GCN: [[DEF:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
338 ; GCN-NEXT: [[DEF1:%[0-9]+]]:vgpr_32 = IMPLICIT_DEF
339 ; GCN-NEXT: [[V_FMAAK_F32_:%[0-9]+]]:vgpr_32 = V_FMAAK_F32 [[DEF]], [[DEF1]], 305419896, implicit $mode, implicit $exec
340 ; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_FMAAK_F32_]]
341 %0:vgpr_32 = IMPLICIT_DEF
342 %1:vgpr_32 = IMPLICIT_DEF
343 %2:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
344 %3:vgpr_32 = V_FMA_F32_e64 0, %0, 0, %1, 0, %2.sub1, 0, 0, implicit $mode, implicit $exec
345 SI_RETURN_TO_EPILOG %3