1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=aarch64 -run-pass=instruction-select -global-isel-abort=1 -verify-machineinstrs %s -o - | FileCheck %s
4 # Verify the following:
6 # - We can fold compares into selects.
7 # - This only happens when the result of the compare is only used by selects.
9 # Also verify that, for now:
11 # - We only support condition flags that require a single instruction.
16 name: fcmp_more_than_one_user_no_fold
20 tracksRegLiveness: true
23 liveins: $s0, $s1, $w1
25 ; CHECK-LABEL: name: fcmp_more_than_one_user_no_fold
26 ; CHECK: liveins: $s0, $s1, $w1
28 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
29 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s1
30 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
31 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
32 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
33 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[CSINCWr]], 0, implicit-def $nzcv
34 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[FMOVS0_]], [[COPY1]], 1, implicit $nzcv
35 ; CHECK-NEXT: $w1 = COPY [[CSINCWr]]
36 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
37 ; CHECK-NEXT: RET_ReallyLR implicit $s0
38 %0:fpr(s32) = COPY $s0
39 %1:fpr(s32) = COPY $s1
40 %2:fpr(s32) = G_FCONSTANT float 0.000000e+00
41 %5:gpr(s32) = G_FCMP floatpred(oeq), %0(s32), %2
42 %4:fpr(s32) = G_SELECT %5, %2, %1
45 RET_ReallyLR implicit $s0
49 name: fcmp_more_than_one_select
53 tracksRegLiveness: true
56 liveins: $s0, $s1, $w1
58 ; CHECK-LABEL: name: fcmp_more_than_one_select
59 ; CHECK: liveins: $s0, $s1, $w1
61 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
62 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s1
63 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
64 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
65 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[FMOVS0_]], [[COPY1]], 0, implicit $nzcv
66 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
67 ; CHECK-NEXT: [[FCSELSrrr1:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY1]], [[FMOVS0_]], 0, implicit $nzcv
68 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
69 ; CHECK-NEXT: $s1 = COPY [[FCSELSrrr1]]
70 ; CHECK-NEXT: RET_ReallyLR implicit $s0
71 %0:fpr(s32) = COPY $s0
72 %1:fpr(s32) = COPY $s1
73 %2:fpr(s32) = G_FCONSTANT float 0.000000e+00
74 %5:gpr(s32) = G_FCMP floatpred(oeq), %0(s32), %2
75 %4:fpr(s32) = G_SELECT %5, %2, %1
76 %7:fpr(s32) = G_SELECT %5, %1, %2
79 RET_ReallyLR implicit $s0
87 tracksRegLiveness: true
92 ; CHECK-LABEL: name: using_icmp
93 ; CHECK: liveins: $s0, $w0
95 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32sp = COPY $w0
96 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s0
97 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
98 ; CHECK-NEXT: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 0, 0, implicit-def $nzcv
99 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY1]], [[FMOVS0_]], 0, implicit $nzcv
100 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
101 ; CHECK-NEXT: RET_ReallyLR implicit $s0
102 %0:gpr(s32) = COPY $w0
103 %1:fpr(s32) = COPY $s0
104 %2:gpr(s32) = G_CONSTANT i32 0
105 %5:fpr(s32) = G_FCONSTANT float 0.000000e+00
106 %6:gpr(s32) = G_ICMP intpred(eq), %0(s32), %2
107 %4:fpr(s32) = G_SELECT %6, %1, %5
109 RET_ReallyLR implicit $s0
116 regBankSelected: true
117 tracksRegLiveness: true
122 ; CHECK-LABEL: name: foeq
123 ; CHECK: liveins: $s0, $s1
125 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
126 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s1
127 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
128 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
129 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[FMOVS0_]], [[COPY1]], 0, implicit $nzcv
130 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
131 ; CHECK-NEXT: RET_ReallyLR implicit $s0
132 %0:fpr(s32) = COPY $s0
133 %1:fpr(s32) = COPY $s1
134 %2:fpr(s32) = G_FCONSTANT float 0.000000e+00
135 %5:gpr(s32) = G_FCMP floatpred(oeq), %0(s32), %2
136 %4:fpr(s32) = G_SELECT %5, %2, %1
138 RET_ReallyLR implicit $s0
145 regBankSelected: true
146 tracksRegLiveness: true
151 ; CHECK-LABEL: name: fueq
152 ; CHECK: liveins: $s0, $s1
154 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
155 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s1
156 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
157 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
158 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
159 ; CHECK-NEXT: [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
160 ; CHECK-NEXT: [[ORRWrr:%[0-9]+]]:gpr32 = ORRWrr [[CSINCWr]], [[CSINCWr1]]
161 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[ORRWrr]], 0, implicit-def $nzcv
162 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[FMOVS0_]], [[COPY1]], 1, implicit $nzcv
163 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
164 ; CHECK-NEXT: RET_ReallyLR implicit $s0
165 %0:fpr(s32) = COPY $s0
166 %1:fpr(s32) = COPY $s1
167 %2:fpr(s32) = G_FCONSTANT float 0.000000e+00
168 %5:gpr(s32) = G_FCMP floatpred(ueq), %0(s32), %2
169 %4:fpr(s32) = G_SELECT %5, %2, %1
171 RET_ReallyLR implicit $s0
178 regBankSelected: true
179 tracksRegLiveness: true
184 ; CHECK-LABEL: name: fone
185 ; CHECK: liveins: $s0, $s1
187 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
188 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s1
189 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
190 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
191 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
192 ; CHECK-NEXT: [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
193 ; CHECK-NEXT: [[ORRWrr:%[0-9]+]]:gpr32 = ORRWrr [[CSINCWr]], [[CSINCWr1]]
194 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[ORRWrr]], 0, implicit-def $nzcv
195 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY1]], [[FMOVS0_]], 1, implicit $nzcv
196 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
197 ; CHECK-NEXT: RET_ReallyLR implicit $s0
198 %0:fpr(s32) = COPY $s0
199 %1:fpr(s32) = COPY $s1
200 %2:fpr(s32) = G_FCONSTANT float 0.000000e+00
201 %5:gpr(s32) = G_FCMP floatpred(one), %0(s32), %2
202 %4:fpr(s32) = G_SELECT %5, %1, %2
204 RET_ReallyLR implicit $s0
211 regBankSelected: true
212 tracksRegLiveness: true
217 ; CHECK-LABEL: name: fune
218 ; CHECK: liveins: $s0, $s1
220 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
221 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s1
222 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
223 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY]], implicit-def $nzcv
224 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY1]], [[FMOVS0_]], 1, implicit $nzcv
225 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
226 ; CHECK-NEXT: RET_ReallyLR implicit $s0
227 %0:fpr(s32) = COPY $s0
228 %1:fpr(s32) = COPY $s1
229 %2:fpr(s32) = G_FCONSTANT float 0.000000e+00
230 %5:gpr(s32) = G_FCMP floatpred(une), %0(s32), %2
231 %4:fpr(s32) = G_SELECT %5, %1, %2
233 RET_ReallyLR implicit $s0
240 regBankSelected: true
241 tracksRegLiveness: true
246 ; CHECK-LABEL: name: doeq
247 ; CHECK: liveins: $d0, $d1
249 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $d0
250 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr64 = COPY $d1
251 ; CHECK-NEXT: [[FMOVD0_:%[0-9]+]]:fpr64 = FMOVD0
252 ; CHECK-NEXT: nofpexcept FCMPDri [[COPY]], implicit-def $nzcv
253 ; CHECK-NEXT: [[FCSELDrrr:%[0-9]+]]:fpr64 = FCSELDrrr [[FMOVD0_]], [[COPY1]], 0, implicit $nzcv
254 ; CHECK-NEXT: $d0 = COPY [[FCSELDrrr]]
255 ; CHECK-NEXT: RET_ReallyLR implicit $d0
256 %0:fpr(s64) = COPY $d0
257 %1:fpr(s64) = COPY $d1
258 %2:fpr(s64) = G_FCONSTANT double 0.000000e+00
259 %5:gpr(s32) = G_FCMP floatpred(oeq), %0(s64), %2
260 %4:fpr(s64) = G_SELECT %5, %2, %1
262 RET_ReallyLR implicit $d0
269 regBankSelected: true
270 tracksRegLiveness: true
275 ; CHECK-LABEL: name: dueq
276 ; CHECK: liveins: $d0, $d1
278 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $d0
279 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr64 = COPY $d1
280 ; CHECK-NEXT: [[FMOVD0_:%[0-9]+]]:fpr64 = FMOVD0
281 ; CHECK-NEXT: nofpexcept FCMPDri [[COPY]], implicit-def $nzcv
282 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
283 ; CHECK-NEXT: [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 7, implicit $nzcv
284 ; CHECK-NEXT: [[ORRWrr:%[0-9]+]]:gpr32 = ORRWrr [[CSINCWr]], [[CSINCWr1]]
285 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[ORRWrr]], 0, implicit-def $nzcv
286 ; CHECK-NEXT: [[FCSELDrrr:%[0-9]+]]:fpr64 = FCSELDrrr [[FMOVD0_]], [[COPY1]], 1, implicit $nzcv
287 ; CHECK-NEXT: $d0 = COPY [[FCSELDrrr]]
288 ; CHECK-NEXT: RET_ReallyLR implicit $d0
289 %0:fpr(s64) = COPY $d0
290 %1:fpr(s64) = COPY $d1
291 %2:fpr(s64) = G_FCONSTANT double 0.000000e+00
292 %5:gpr(s32) = G_FCMP floatpred(ueq), %0(s64), %2
293 %4:fpr(s64) = G_SELECT %5, %2, %1
295 RET_ReallyLR implicit $d0
302 regBankSelected: true
303 tracksRegLiveness: true
308 ; CHECK-LABEL: name: done
309 ; CHECK: liveins: $d0, $d1
311 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $d0
312 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr64 = COPY $d1
313 ; CHECK-NEXT: [[FMOVD0_:%[0-9]+]]:fpr64 = FMOVD0
314 ; CHECK-NEXT: nofpexcept FCMPDri [[COPY]], implicit-def $nzcv
315 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
316 ; CHECK-NEXT: [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
317 ; CHECK-NEXT: [[ORRWrr:%[0-9]+]]:gpr32 = ORRWrr [[CSINCWr]], [[CSINCWr1]]
318 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[ORRWrr]], 0, implicit-def $nzcv
319 ; CHECK-NEXT: [[FCSELDrrr:%[0-9]+]]:fpr64 = FCSELDrrr [[COPY1]], [[FMOVD0_]], 1, implicit $nzcv
320 ; CHECK-NEXT: $d0 = COPY [[FCSELDrrr]]
321 ; CHECK-NEXT: RET_ReallyLR implicit $d0
322 %0:fpr(s64) = COPY $d0
323 %1:fpr(s64) = COPY $d1
324 %2:fpr(s64) = G_FCONSTANT double 0.000000e+00
325 %5:gpr(s32) = G_FCMP floatpred(one), %0(s64), %2
326 %4:fpr(s64) = G_SELECT %5, %1, %2
328 RET_ReallyLR implicit $d0
335 regBankSelected: true
336 tracksRegLiveness: true
341 ; CHECK-LABEL: name: dune
342 ; CHECK: liveins: $d0, $d1
344 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr64 = COPY $d0
345 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr64 = COPY $d1
346 ; CHECK-NEXT: [[FMOVD0_:%[0-9]+]]:fpr64 = FMOVD0
347 ; CHECK-NEXT: nofpexcept FCMPDri [[COPY]], implicit-def $nzcv
348 ; CHECK-NEXT: [[FCSELDrrr:%[0-9]+]]:fpr64 = FCSELDrrr [[COPY1]], [[FMOVD0_]], 1, implicit $nzcv
349 ; CHECK-NEXT: $d0 = COPY [[FCSELDrrr]]
350 ; CHECK-NEXT: RET_ReallyLR implicit $d0
351 %0:fpr(s64) = COPY $d0
352 %1:fpr(s64) = COPY $d1
353 %2:fpr(s64) = G_FCONSTANT double 0.000000e+00
354 %5:gpr(s32) = G_FCMP floatpred(une), %0(s64), %2
355 %4:fpr(s64) = G_SELECT %5, %1, %2
357 RET_ReallyLR implicit $d0
361 name: copy_from_physreg
364 regBankSelected: true
365 tracksRegLiveness: true
368 liveins: $s0, $w0, $w1
370 ; CHECK-LABEL: name: copy_from_physreg
371 ; CHECK: liveins: $s0, $w0, $w1
373 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
374 ; CHECK-NEXT: [[FMOVS0_:%[0-9]+]]:fpr32 = FMOVS0
375 ; CHECK-NEXT: BL @copy_from_physreg, implicit-def $w0
376 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY [[FMOVS0_]]
377 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[COPY1]], 0, implicit-def $nzcv
378 ; CHECK-NEXT: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY]], [[FMOVS0_]], 1, implicit $nzcv
379 ; CHECK-NEXT: BL @copy_from_physreg, implicit-def $w0
380 ; CHECK-NEXT: $s0 = COPY [[FCSELSrrr]]
381 ; CHECK-NEXT: RET_ReallyLR implicit $s0
382 %0:gpr(s32) = COPY $w0
383 %1:fpr(s32) = COPY $s0
384 %5:fpr(s32) = G_FCONSTANT float 0.000000e+00
385 BL @copy_from_physreg, implicit-def $w0
386 %4:fpr(s32) = G_SELECT %5, %1, %5
387 BL @copy_from_physreg, implicit-def $w0
389 RET_ReallyLR implicit $s0