1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple arm64-- -run-pass=regbankselect %s -o - | FileCheck %s
4 # Check that we correctly assign register banks based off of instructions which
5 # only use or only define FPRs.
7 # For example, G_SITOFP may take in a GPR, but only ever produces values on FPRs.
8 # Some instructions can have inputs/outputs on either FPRs or GPRs. If one of
9 # those instructions takes in the result of a G_SITOFP as a source, we should
10 # put that source on a FPR.
12 # Similarly, G_FPTOSI can only take in a value on a FPR. So, if the result of
13 # an instruction is consumed by a G_FPTOSI, we should put the instruction on
17 name: load_only_uses_fp
19 tracksRegLiveness: true
23 ; CHECK-LABEL: name: load_only_uses_fp
26 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
27 ; CHECK-NEXT: [[C:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 2.000000e+00
28 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:fpr(s32) = G_LOAD [[COPY]](p0) :: (load (s32))
29 ; CHECK-NEXT: [[FCMP:%[0-9]+]]:gpr(s32) = G_FCMP floatpred(uno), [[C]](s32), [[LOAD]]
30 ; CHECK-NEXT: $w0 = COPY [[FCMP]](s32)
31 ; CHECK-NEXT: RET_ReallyLR implicit $w0
33 %1:_(s32) = G_FCONSTANT float 2.0
34 %2:_(s32) = G_LOAD %0 :: (load (s32))
35 %3:_(s32) = G_FCMP floatpred(uno), %1, %2
37 RET_ReallyLR implicit $w0
40 name: unmerge_only_uses_fp
43 tracksRegLiveness: true
47 ; CHECK-LABEL: name: unmerge_only_uses_fp
50 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(s64) = COPY $x0
51 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr(s64) = COPY [[COPY]](s64)
52 ; CHECK-NEXT: [[UV:%[0-9]+]]:fpr(s32), [[UV1:%[0-9]+]]:fpr(s32) = G_UNMERGE_VALUES [[COPY1]](s64)
53 ; CHECK-NEXT: [[FCMP:%[0-9]+]]:gpr(s32) = G_FCMP floatpred(uno), [[UV]](s32), [[UV1]]
54 ; CHECK-NEXT: $w0 = COPY [[FCMP]](s32)
55 ; CHECK-NEXT: RET_ReallyLR implicit $w0
57 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(s64)
58 %3:_(s32) = G_FCMP floatpred(uno), %1, %2
60 RET_ReallyLR implicit $w0
64 name: store_defined_by_fp
66 tracksRegLiveness: true
70 ; CHECK-LABEL: name: store_defined_by_fp
71 ; CHECK: liveins: $x0, $w1
73 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
74 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr(s32) = COPY $w1
75 ; CHECK-NEXT: [[SITOFP:%[0-9]+]]:fpr(s32) = G_SITOFP [[COPY1]](s32)
76 ; CHECK-NEXT: G_STORE [[SITOFP]](s32), [[COPY]](p0) :: (store (s32))
79 %2:_(s32) = G_SITOFP %1
80 G_STORE %2, %0 :: (store (s32))
84 name: select_defined_by_fp_using_fp
86 tracksRegLiveness: true
89 liveins: $w0, $w1, $w2
90 ; CHECK-LABEL: name: select_defined_by_fp_using_fp
91 ; CHECK: liveins: $w0, $w1, $w2
93 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
94 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr(s32) = COPY $w1
95 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr(s32) = COPY $w2
96 ; CHECK-NEXT: [[SITOFP:%[0-9]+]]:fpr(s32) = G_SITOFP [[COPY1]](s32)
97 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:fpr(s32) = COPY [[COPY2]](s32)
98 ; CHECK-NEXT: [[SELECT:%[0-9]+]]:fpr(s32) = G_SELECT [[COPY2]](s32), [[COPY3]], [[SITOFP]]
99 ; CHECK-NEXT: [[FPTOSI:%[0-9]+]]:gpr(s32) = G_FPTOSI [[SELECT]](s32)
103 %4:_(s32) = G_SITOFP %2
104 %6:_(s32) = G_SELECT %3, %3, %4
105 %8:_(s32) = G_FPTOSI %6
109 name: load_used_by_phi_fpr
111 tracksRegLiveness: true
113 ; CHECK-LABEL: name: load_used_by_phi_fpr
115 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
116 ; CHECK-NEXT: liveins: $x0, $s0, $s1, $w0, $w1
118 ; CHECK-NEXT: %cond_wide:gpr(s32) = COPY $w0
119 ; CHECK-NEXT: %fpr_copy:fpr(s32) = COPY $s0
120 ; CHECK-NEXT: %ptr:gpr(p0) = COPY $x0
121 ; CHECK-NEXT: G_BRCOND %cond_wide(s32), %bb.1
122 ; CHECK-NEXT: G_BR %bb.2
125 ; CHECK-NEXT: successors: %bb.2(0x80000000)
127 ; CHECK-NEXT: %load:fpr(s32) = G_LOAD %ptr(p0) :: (load (s32))
128 ; CHECK-NEXT: G_BR %bb.2
131 ; CHECK-NEXT: %phi:fpr(s32) = G_PHI %fpr_copy(s32), %bb.0, %load(s32), %bb.1
132 ; CHECK-NEXT: $s0 = COPY %phi(s32)
133 ; CHECK-NEXT: RET_ReallyLR implicit $s0
135 successors: %bb.1(0x40000000), %bb.2(0x40000000)
136 liveins: $x0, $s0, $s1, $w0, $w1
137 %cond_wide:_(s32) = COPY $w0
138 %fpr_copy:_(s32) = COPY $s0
139 %ptr:_(p0) = COPY $x0
140 G_BRCOND %cond_wide, %bb.1
144 %load:_(s32) = G_LOAD %ptr(p0) :: (load (s32))
147 %phi:_(s32) = G_PHI %fpr_copy(s32), %bb.0, %load(s32), %bb.1
149 RET_ReallyLR implicit $s0
153 name: load_used_by_phi_gpr
155 tracksRegLiveness: true
157 ; CHECK-LABEL: name: load_used_by_phi_gpr
159 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
160 ; CHECK-NEXT: liveins: $x0, $s0, $s1, $w0, $w1
162 ; CHECK-NEXT: %cond_wide:gpr(s32) = COPY $w0
163 ; CHECK-NEXT: %gpr_copy:gpr(s32) = COPY $w1
164 ; CHECK-NEXT: %ptr:gpr(p0) = COPY $x0
165 ; CHECK-NEXT: G_BRCOND %cond_wide(s32), %bb.1
166 ; CHECK-NEXT: G_BR %bb.2
169 ; CHECK-NEXT: successors: %bb.2(0x80000000)
171 ; CHECK-NEXT: %load:gpr(s32) = G_LOAD %ptr(p0) :: (load (s32))
172 ; CHECK-NEXT: G_BR %bb.2
175 ; CHECK-NEXT: %phi:gpr(s32) = G_PHI %gpr_copy(s32), %bb.0, %load(s32), %bb.1
176 ; CHECK-NEXT: $s0 = COPY %phi(s32)
177 ; CHECK-NEXT: RET_ReallyLR implicit $s0
179 successors: %bb.1(0x40000000), %bb.2(0x40000000)
180 liveins: $x0, $s0, $s1, $w0, $w1
181 %cond_wide:_(s32) = COPY $w0
182 %gpr_copy:_(s32) = COPY $w1
183 %ptr:_(p0) = COPY $x0
184 G_BRCOND %cond_wide, %bb.1
188 %load:_(s32) = G_LOAD %ptr(p0) :: (load (s32))
191 %phi:_(s32) = G_PHI %gpr_copy(s32), %bb.0, %load(s32), %bb.1
193 RET_ReallyLR implicit $s0
197 name: select_used_by_phi_fpr
199 tracksRegLiveness: true
201 ; CHECK-LABEL: name: select_used_by_phi_fpr
203 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
204 ; CHECK-NEXT: liveins: $s0, $s1, $w0, $w1
206 ; CHECK-NEXT: %cond_wide:gpr(s32) = COPY $w0
207 ; CHECK-NEXT: %fpr_copy:fpr(s32) = COPY $s0
208 ; CHECK-NEXT: %gpr_copy:gpr(s32) = COPY $w1
209 ; CHECK-NEXT: G_BRCOND %cond_wide(s32), %bb.1
210 ; CHECK-NEXT: G_BR %bb.2
213 ; CHECK-NEXT: successors: %bb.2(0x80000000)
215 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr(s32) = COPY %gpr_copy(s32)
216 ; CHECK-NEXT: %select:fpr(s32) = G_SELECT %cond_wide(s32), %fpr_copy, [[COPY]]
217 ; CHECK-NEXT: G_BR %bb.2
220 ; CHECK-NEXT: %phi:fpr(s32) = G_PHI %fpr_copy(s32), %bb.0, %select(s32), %bb.1
221 ; CHECK-NEXT: $w0 = COPY %phi(s32)
222 ; CHECK-NEXT: RET_ReallyLR implicit $w0
223 ; The G_SELECT and G_PHI should end up with the same register bank.
226 successors: %bb.1(0x40000000), %bb.2(0x40000000)
227 liveins: $s0, $s1, $w0, $w1
228 %cond_wide:_(s32) = COPY $w0
229 %fpr_copy:_(s32) = COPY $s0
230 %gpr_copy:_(s32) = COPY $w1
231 G_BRCOND %cond_wide, %bb.1
235 %select:_(s32) = G_SELECT %cond_wide, %fpr_copy, %gpr_copy
238 %phi:_(s32) = G_PHI %fpr_copy(s32), %bb.0, %select(s32), %bb.1
240 RET_ReallyLR implicit $w0
244 name: select_used_by_phi_gpr
246 tracksRegLiveness: true
248 ; CHECK-LABEL: name: select_used_by_phi_gpr
250 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
251 ; CHECK-NEXT: liveins: $s0, $s1, $w0, $w1
253 ; CHECK-NEXT: %cond_wide:gpr(s32) = COPY $w0
254 ; CHECK-NEXT: %fpr_copy:fpr(s32) = COPY $s0
255 ; CHECK-NEXT: %gpr_copy:gpr(s32) = COPY $w1
256 ; CHECK-NEXT: G_BRCOND %cond_wide(s32), %bb.1
257 ; CHECK-NEXT: G_BR %bb.2
260 ; CHECK-NEXT: successors: %bb.2(0x80000000)
262 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(s32) = COPY %fpr_copy(s32)
263 ; CHECK-NEXT: %select:gpr(s32) = G_SELECT %cond_wide(s32), [[COPY]], %gpr_copy
264 ; CHECK-NEXT: G_BR %bb.2
267 ; CHECK-NEXT: %phi:gpr(s32) = G_PHI %gpr_copy(s32), %bb.0, %select(s32), %bb.1
268 ; CHECK-NEXT: $s0 = COPY %phi(s32)
269 ; CHECK-NEXT: RET_ReallyLR implicit $s0
270 ; The G_SELECT and G_PHI should end up with the same register bank.
273 successors: %bb.1(0x40000000), %bb.2(0x40000000)
274 liveins: $s0, $s1, $w0, $w1
275 %cond_wide:_(s32) = COPY $w0
276 %fpr_copy:_(s32) = COPY $s0
277 %gpr_copy:_(s32) = COPY $w1
278 G_BRCOND %cond_wide, %bb.1
282 %select:_(s32) = G_SELECT %cond_wide, %fpr_copy, %gpr_copy
285 %phi:_(s32) = G_PHI %gpr_copy(s32), %bb.0, %select(s32), %bb.1
287 RET_ReallyLR implicit $s0
292 name: unmerge_used_by_phi_fpr
294 tracksRegLiveness: true
296 ; CHECK-LABEL: name: unmerge_used_by_phi_fpr
298 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
299 ; CHECK-NEXT: liveins: $x0, $s0, $s1, $w0, $w1
301 ; CHECK-NEXT: %cond_wide:gpr(s32) = COPY $w0
302 ; CHECK-NEXT: %fpr_copy:fpr(s32) = COPY $s0
303 ; CHECK-NEXT: %unmerge_src:gpr(s64) = COPY $x0
304 ; CHECK-NEXT: G_BRCOND %cond_wide(s32), %bb.1
305 ; CHECK-NEXT: G_BR %bb.2
308 ; CHECK-NEXT: successors: %bb.2(0x80000000)
310 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr(s64) = COPY %unmerge_src(s64)
311 ; CHECK-NEXT: %unmerge_1:fpr(s32), %unmerge_2:fpr(s32) = G_UNMERGE_VALUES [[COPY]](s64)
312 ; CHECK-NEXT: G_BR %bb.2
315 ; CHECK-NEXT: %phi:fpr(s32) = G_PHI %fpr_copy(s32), %bb.0, %unmerge_1(s32), %bb.1
316 ; CHECK-NEXT: $s0 = COPY %phi(s32)
317 ; CHECK-NEXT: RET_ReallyLR implicit $s0
319 successors: %bb.1(0x40000000), %bb.2(0x40000000)
320 liveins: $x0, $s0, $s1, $w0, $w1
321 %cond_wide:_(s32) = COPY $w0
323 %fpr_copy:_(s32) = COPY $s0
324 %unmerge_src:_(s64) = COPY $x0
325 G_BRCOND %cond_wide, %bb.1
329 %unmerge_1:_(s32), %unmerge_2:_(s32) = G_UNMERGE_VALUES %unmerge_src(s64)
332 %phi:_(s32) = G_PHI %fpr_copy(s32), %bb.0, %unmerge_1(s32), %bb.1
334 RET_ReallyLR implicit $s0
338 name: unmerge_used_by_phi_gpr
340 tracksRegLiveness: true
342 ; CHECK-LABEL: name: unmerge_used_by_phi_gpr
344 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
345 ; CHECK-NEXT: liveins: $x0, $s0, $s1, $w0, $w1
347 ; CHECK-NEXT: %cond_wide:gpr(s32) = COPY $w0
348 ; CHECK-NEXT: %gpr_copy:gpr(s32) = COPY $w1
349 ; CHECK-NEXT: %unmerge_src:gpr(s64) = COPY $x0
350 ; CHECK-NEXT: G_BRCOND %cond_wide(s32), %bb.1
351 ; CHECK-NEXT: G_BR %bb.2
354 ; CHECK-NEXT: successors: %bb.2(0x80000000)
356 ; CHECK-NEXT: %unmerge_1:gpr(s32), %unmerge_2:gpr(s32) = G_UNMERGE_VALUES %unmerge_src(s64)
357 ; CHECK-NEXT: G_BR %bb.2
360 ; CHECK-NEXT: %phi:gpr(s32) = G_PHI %gpr_copy(s32), %bb.0, %unmerge_1(s32), %bb.1
361 ; CHECK-NEXT: $s0 = COPY %phi(s32)
362 ; CHECK-NEXT: RET_ReallyLR implicit $s0
364 successors: %bb.1(0x40000000), %bb.2(0x40000000)
365 liveins: $x0, $s0, $s1, $w0, $w1
366 %cond_wide:_(s32) = COPY $w0
367 %gpr_copy:_(s32) = COPY $w1
368 %unmerge_src:_(s64) = COPY $x0
369 G_BRCOND %cond_wide, %bb.1
373 %unmerge_1:_(s32), %unmerge_2:_(s32) = G_UNMERGE_VALUES %unmerge_src(s64)
376 %phi:_(s32) = G_PHI %gpr_copy(s32), %bb.0, %unmerge_1(s32), %bb.1
378 RET_ReallyLR implicit $s0
382 name: load_used_by_sitofp
384 tracksRegLiveness: true
388 ; The load should be assigned an fpr bank because it's used by the sitofp.
389 ; The sitofp should assign both src and dest to FPR, resulting in no copies.
390 ; CHECK-LABEL: name: load_used_by_sitofp
391 ; CHECK: liveins: $x0
393 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
394 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:fpr(s32) = G_LOAD [[COPY]](p0) :: (load (s32))
395 ; CHECK-NEXT: [[SITOFP:%[0-9]+]]:fpr(s32) = G_SITOFP [[LOAD]](s32)
396 ; CHECK-NEXT: $s0 = COPY [[SITOFP]](s32)
397 ; CHECK-NEXT: RET_ReallyLR implicit $s0
399 %1:_(s32) = G_LOAD %0 :: (load (s32))
400 %2:_(s32) = G_SITOFP %1:_(s32)
402 RET_ReallyLR implicit $s0
405 name: load_used_by_uitofp
407 tracksRegLiveness: true
411 ; CHECK-LABEL: name: load_used_by_uitofp
412 ; CHECK: liveins: $x0
414 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
415 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:fpr(s32) = G_LOAD [[COPY]](p0) :: (load (s32))
416 ; CHECK-NEXT: [[UITOFP:%[0-9]+]]:fpr(s32) = G_UITOFP [[LOAD]](s32)
417 ; CHECK-NEXT: $s0 = COPY [[UITOFP]](s32)
418 ; CHECK-NEXT: RET_ReallyLR implicit $s0
420 %1:_(s32) = G_LOAD %0 :: (load (s32))
421 %2:_(s32) = G_UITOFP %1:_(s32)
423 RET_ReallyLR implicit $s0