1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-apple-darwin -run-pass=regbankselect -verify-machineinstrs %s -o - | FileCheck %s
9 tracksRegLiveness: true
10 machineFunctionInfo: {}
13 liveins: $s0, $s1, $w0
15 ; CHECK-LABEL: name: select_f32
16 ; CHECK: liveins: $s0, $s1, $w0
17 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
18 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[COPY]](s32)
19 ; CHECK: [[COPY1:%[0-9]+]]:fpr(s32) = COPY $s0
20 ; CHECK: [[COPY2:%[0-9]+]]:fpr(s32) = COPY $s1
21 ; CHECK: [[SELECT:%[0-9]+]]:fpr(s32) = G_SELECT [[TRUNC]](s1), [[COPY1]], [[COPY2]]
22 ; CHECK: $s0 = COPY [[SELECT]](s32)
23 ; CHECK: RET_ReallyLR implicit $s0
25 %0:_(s1) = G_TRUNC %3(s32)
28 %4:_(s32) = G_SELECT %0(s1), %1, %2
30 RET_ReallyLR implicit $s0
37 tracksRegLiveness: true
38 machineFunctionInfo: {}
41 liveins: $d0, $d1, $w0
43 ; CHECK-LABEL: name: select_f64
44 ; CHECK: liveins: $d0, $d1, $w0
45 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
46 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[COPY]](s32)
47 ; CHECK: [[COPY1:%[0-9]+]]:fpr(s64) = COPY $d0
48 ; CHECK: [[COPY2:%[0-9]+]]:fpr(s64) = COPY $d1
49 ; CHECK: [[SELECT:%[0-9]+]]:fpr(s64) = G_SELECT [[TRUNC]](s1), [[COPY1]], [[COPY2]]
50 ; CHECK: $d0 = COPY [[SELECT]](s64)
51 ; CHECK: RET_ReallyLR implicit $d0
53 %0:_(s1) = G_TRUNC %3(s32)
56 %4:_(s64) = G_SELECT %0(s1), %1, %2
58 RET_ReallyLR implicit $d0
62 name: two_fpr_inputs_gpr_output
65 tracksRegLiveness: true
66 machineFunctionInfo: {}
69 liveins: $d0, $d1, $w0
70 ; CHECK-LABEL: name: two_fpr_inputs_gpr_output
71 ; CHECK: liveins: $d0, $d1, $w0
72 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
73 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[COPY]](s32)
74 ; CHECK: [[COPY1:%[0-9]+]]:fpr(s64) = COPY $d0
75 ; CHECK: [[COPY2:%[0-9]+]]:fpr(s64) = COPY $d1
76 ; CHECK: [[SELECT:%[0-9]+]]:fpr(s64) = G_SELECT [[TRUNC]](s1), [[COPY1]], [[COPY2]]
77 ; CHECK: $x0 = COPY [[SELECT]](s64)
78 ; CHECK: RET_ReallyLR implicit $x0
80 ; Verify that the G_SELECT only has FPRs.
81 ; The only difference between fcsel and csel are the register banks. So,
82 ; if we have two FPR inputs and a GPR output, we should do a floating point
83 ; select anyway. This will cost one copy for the output, but that's less
84 ; than doing two to put the inputs on GPRs.
87 %0:_(s1) = G_TRUNC %3(s32)
90 %4:_(s64) = G_SELECT %0(s1), %1, %2
92 RET_ReallyLR implicit $x0
96 name: one_fpr_input_fpr_output
99 tracksRegLiveness: true
100 machineFunctionInfo: {}
103 liveins: $d0, $x1, $w0
104 ; CHECK-LABEL: name: one_fpr_input_fpr_output
105 ; CHECK: liveins: $d0, $x1, $w0
106 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
107 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[COPY]](s32)
108 ; CHECK: [[COPY1:%[0-9]+]]:fpr(s64) = COPY $d0
109 ; CHECK: [[COPY2:%[0-9]+]]:gpr(s64) = COPY $x1
110 ; CHECK: [[COPY3:%[0-9]+]]:fpr(s64) = COPY [[COPY2]](s64)
111 ; CHECK: [[SELECT:%[0-9]+]]:fpr(s64) = G_SELECT [[TRUNC]](s1), [[COPY1]], [[COPY3]]
112 ; CHECK: $d0 = COPY [[SELECT]](s64)
113 ; CHECK: RET_ReallyLR implicit $d0
115 ; Same idea as the above test. If the output is an FPR, and one of the
116 ; inputs is an FPR, then it's fewer copies to just do a FCSEL.
119 %0:_(s1) = G_TRUNC %3(s32)
122 %4:_(s64) = G_SELECT %0(s1), %1, %2
124 RET_ReallyLR implicit $d0
128 name: one_fpr_input_gpr_output
131 tracksRegLiveness: true
132 machineFunctionInfo: {}
135 liveins: $d0, $x1, $w0
136 ; CHECK-LABEL: name: one_fpr_input_gpr_output
137 ; CHECK: liveins: $d0, $x1, $w0
138 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
139 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[COPY]](s32)
140 ; CHECK: [[COPY1:%[0-9]+]]:fpr(s64) = COPY $d0
141 ; CHECK: [[COPY2:%[0-9]+]]:gpr(s64) = COPY $x1
142 ; CHECK: [[COPY3:%[0-9]+]]:gpr(s64) = COPY [[COPY1]](s64)
143 ; CHECK: [[SELECT:%[0-9]+]]:gpr(s64) = G_SELECT [[TRUNC]](s1), [[COPY3]], [[COPY2]]
144 ; CHECK: $x0 = COPY [[SELECT]](s64)
145 ; CHECK: RET_ReallyLR implicit $x0
147 ; Now we have more GPR registers on the G_SELECT. It's cheaper here to put
151 %0:_(s1) = G_TRUNC %3(s32)
154 %4:_(s64) = G_SELECT %0(s1), %1, %2
156 RET_ReallyLR implicit $x0
160 name: two_gpr_input_fpr_output
163 tracksRegLiveness: true
164 machineFunctionInfo: {}
167 liveins: $x0, $x1, $w0
168 ; CHECK-LABEL: name: two_gpr_input_fpr_output
169 ; CHECK: liveins: $x0, $x1, $w0
170 ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
171 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[COPY]](s32)
172 ; CHECK: [[COPY1:%[0-9]+]]:gpr(s64) = COPY $x0
173 ; CHECK: [[COPY2:%[0-9]+]]:gpr(s64) = COPY $x1
174 ; CHECK: [[SELECT:%[0-9]+]]:gpr(s64) = G_SELECT [[TRUNC]](s1), [[COPY1]], [[COPY2]]
175 ; CHECK: $d0 = COPY [[SELECT]](s64)
176 ; CHECK: RET_ReallyLR implicit $d0
178 ; Same as above. The G_SELECT should get all GPRS.
181 %0:_(s1) = G_TRUNC %3(s32)
184 %4:_(s64) = G_SELECT %0(s1), %1, %2
186 RET_ReallyLR implicit $d0