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 takes 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
25 ; CHECK: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
26 ; CHECK: [[C:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 2.000000e+00
27 ; CHECK: [[LOAD:%[0-9]+]]:fpr(s32) = G_LOAD [[COPY]](p0) :: (load 4)
28 ; CHECK: [[FCMP:%[0-9]+]]:gpr(s32) = G_FCMP floatpred(uno), [[C]](s32), [[LOAD]]
29 ; CHECK: $w0 = COPY [[FCMP]](s32)
30 ; CHECK: RET_ReallyLR implicit $w0
32 %1:_(s32) = G_FCONSTANT float 2.0
33 %2:_(s32) = G_LOAD %0 :: (load 4)
34 %3:_(s32) = G_FCMP floatpred(uno), %1, %2
36 RET_ReallyLR implicit $w0
39 name: unmerge_only_uses_fp
42 tracksRegLiveness: true
46 ; CHECK-LABEL: name: unmerge_only_uses_fp
48 ; CHECK: [[COPY:%[0-9]+]]:gpr(s64) = COPY $x0
49 ; CHECK: [[COPY1:%[0-9]+]]:fpr(s64) = COPY [[COPY]](s64)
50 ; CHECK: [[UV:%[0-9]+]]:fpr(s32), [[UV1:%[0-9]+]]:fpr(s32) = G_UNMERGE_VALUES [[COPY1]](s64)
51 ; CHECK: [[FCMP:%[0-9]+]]:gpr(s32) = G_FCMP floatpred(uno), [[UV]](s32), [[UV1]]
52 ; CHECK: $w0 = COPY [[FCMP]](s32)
53 ; CHECK: RET_ReallyLR implicit $w0
55 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0(s64)
56 %3:_(s32) = G_FCMP floatpred(uno), %1, %2
58 RET_ReallyLR implicit $w0
62 name: store_defined_by_fp
64 tracksRegLiveness: true
68 ; CHECK-LABEL: name: store_defined_by_fp
69 ; CHECK: liveins: $x0, $w1
70 ; CHECK: [[COPY:%[0-9]+]]:gpr(p0) = COPY $x0
71 ; CHECK: [[COPY1:%[0-9]+]]:gpr(s32) = COPY $w1
72 ; CHECK: [[SITOFP:%[0-9]+]]:fpr(s32) = G_SITOFP [[COPY1]](s32)
73 ; CHECK: G_STORE [[SITOFP]](s32), [[COPY]](p0) :: (store 4)
76 %2:_(s32) = G_SITOFP %1
77 G_STORE %2, %0 :: (store 4)
81 name: select_defined_by_fp_using_fp
83 tracksRegLiveness: true
86 liveins: $w0, $w1, $w2
87 ; CHECK-LABEL: name: select_defined_by_fp_using_fp
88 ; CHECK: liveins: $w0, $w1, $w2
89 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
90 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC %2(s32)
91 ; CHECK: [[COPY1:%[0-9]+]]:gpr(s32) = COPY $w1
92 ; CHECK: [[COPY2:%[0-9]+]]:gpr(s32) = COPY $w2
93 ; CHECK: [[SITOFP:%[0-9]+]]:fpr(s32) = G_SITOFP [[COPY1]](s32)
94 ; CHECK: [[COPY3:%[0-9]+]]:fpr(s32) = COPY [[COPY2]](s32)
95 ; CHECK: [[SELECT:%[0-9]+]]:fpr(s32) = G_SELECT [[TRUNC]](s1), [[COPY3]], [[SITOFP]]
96 ; CHECK: [[FPTOSI:%[0-9]+]]:gpr(s32) = G_FPTOSI [[SELECT]](s32)
98 %1:_(s1) = G_TRUNC %3(s32)
101 %4:_(s32) = G_SITOFP %2
102 %6:_(s32) = G_SELECT %1(s1), %3, %4
103 %8:_(s32) = G_FPTOSI %6