1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-apple-darwin -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
10 tracksRegLiveness: true
11 machineFunctionInfo: {}
14 liveins: $s0, $s1, $w0
16 ; CHECK-LABEL: name: select_f32
17 ; CHECK: liveins: $s0, $s1, $w0
18 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
19 ; CHECK: [[COPY1:%[0-9]+]]:fpr32 = COPY $s0
20 ; CHECK: [[COPY2:%[0-9]+]]:fpr32 = COPY $s1
21 ; CHECK: [[COPY3:%[0-9]+]]:fpr32 = COPY [[COPY]]
22 ; CHECK: [[COPY4:%[0-9]+]]:gpr32 = COPY [[COPY3]]
23 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[COPY4]], 0, implicit-def $nzcv
24 ; CHECK: [[FCSELSrrr:%[0-9]+]]:fpr32 = FCSELSrrr [[COPY1]], [[COPY2]], 1, implicit $nzcv
25 ; CHECK: $s0 = COPY [[FCSELSrrr]]
26 ; CHECK: RET_ReallyLR implicit $s0
27 %3:gpr(s32) = COPY $w0
28 %0:gpr(s1) = G_TRUNC %3(s32)
29 %1:fpr(s32) = COPY $s0
30 %2:fpr(s32) = COPY $s1
31 %5:fpr(s1) = COPY %0(s1)
32 %4:fpr(s32) = G_SELECT %5(s1), %1, %2
34 RET_ReallyLR implicit $s0
42 tracksRegLiveness: true
43 machineFunctionInfo: {}
46 liveins: $d0, $d1, $w0
48 ; CHECK-LABEL: name: select_f64
49 ; CHECK: liveins: $d0, $d1, $w0
50 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
51 ; CHECK: [[COPY1:%[0-9]+]]:fpr64 = COPY $d0
52 ; CHECK: [[COPY2:%[0-9]+]]:fpr64 = COPY $d1
53 ; CHECK: [[COPY3:%[0-9]+]]:fpr32 = COPY [[COPY]]
54 ; CHECK: [[COPY4:%[0-9]+]]:gpr32 = COPY [[COPY3]]
55 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[COPY4]], 0, implicit-def $nzcv
56 ; CHECK: [[FCSELDrrr:%[0-9]+]]:fpr64 = FCSELDrrr [[COPY1]], [[COPY2]], 1, implicit $nzcv
57 ; CHECK: $d0 = COPY [[FCSELDrrr]]
58 ; CHECK: RET_ReallyLR implicit $d0
59 %3:gpr(s32) = COPY $w0
60 %0:gpr(s1) = G_TRUNC %3(s32)
61 %1:fpr(s64) = COPY $d0
62 %2:fpr(s64) = COPY $d1
63 %5:fpr(s1) = COPY %0(s1)
64 %4:fpr(s64) = G_SELECT %5(s1), %1, %2
66 RET_ReallyLR implicit $d0
72 tracksRegLiveness: true
75 liveins: $w0, $w1, $w2, $w3
76 ; CHECK-LABEL: name: csel
77 ; CHECK: liveins: $w0, $w1, $w2, $w3
78 ; CHECK: %reg0:gpr32 = COPY $w0
79 ; CHECK: %reg1:gpr32 = COPY $w1
80 ; CHECK: %t:gpr32 = COPY $w2
81 ; CHECK: %f:gpr32 = COPY $w3
82 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
83 ; CHECK: %select:gpr32 = CSELWr %t, %f, 1, implicit $nzcv
84 ; CHECK: $w0 = COPY %select
85 ; CHECK: RET_ReallyLR implicit $w0
86 %reg0:gpr(s32) = COPY $w0
87 %reg1:gpr(s32) = COPY $w1
88 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
89 %cond:gpr(s1) = G_TRUNC %cmp(s32)
90 %t:gpr(s32) = COPY $w2
91 %f:gpr(s32) = COPY $w3
92 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
93 $w0 = COPY %select(s32)
94 RET_ReallyLR implicit $w0
100 tracksRegLiveness: true
104 ; G_SELECT cc, 0, 1 -> CSINC zreg, zreg, cc
106 ; CHECK-LABEL: name: csinc_t_0_f_1
107 ; CHECK: liveins: $w0, $w1
108 ; CHECK: %reg0:gpr32 = COPY $w0
109 ; CHECK: %reg1:gpr32 = COPY $w1
110 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
111 ; CHECK: %select:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
112 ; CHECK: $w0 = COPY %select
113 ; CHECK: RET_ReallyLR implicit $w0
114 %reg0:gpr(s32) = COPY $w0
115 %reg1:gpr(s32) = COPY $w1
116 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
117 %cond:gpr(s1) = G_TRUNC %cmp(s32)
118 %t:gpr(s32) = G_CONSTANT i32 0
119 %f:gpr(s32) = G_CONSTANT i32 1
120 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
121 $w0 = COPY %select(s32)
122 RET_ReallyLR implicit $w0
125 name: csinv_t_0_f_neg_1
127 regBankSelected: true
128 tracksRegLiveness: true
132 ; G_SELECT cc 0, -1 -> CSINV zreg, zreg cc
134 ; CHECK-LABEL: name: csinv_t_0_f_neg_1
135 ; CHECK: liveins: $w0, $w1
136 ; CHECK: %reg0:gpr32 = COPY $w0
137 ; CHECK: %reg1:gpr32 = COPY $w1
138 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
139 ; CHECK: %select:gpr32 = CSINVWr $wzr, $wzr, 1, implicit $nzcv
140 ; CHECK: $w0 = COPY %select
141 ; CHECK: RET_ReallyLR implicit $w0
142 %reg0:gpr(s32) = COPY $w0
143 %reg1:gpr(s32) = COPY $w1
144 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
145 %cond:gpr(s1) = G_TRUNC %cmp(s32)
146 %t:gpr(s32) = G_CONSTANT i32 0
147 %f:gpr(s32) = G_CONSTANT i32 -1
148 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
149 $w0 = COPY %select(s32)
150 RET_ReallyLR implicit $w0
155 regBankSelected: true
156 tracksRegLiveness: true
159 liveins: $w0, $w1, $w2
160 ; G_SELECT cc, 1, f -> CSINC f, zreg, inv_cc
162 ; CHECK-LABEL: name: csinc_t_1
163 ; CHECK: liveins: $w0, $w1, $w2
164 ; CHECK: %reg0:gpr32 = COPY $w0
165 ; CHECK: %reg1:gpr32 = COPY $w1
166 ; CHECK: %f:gpr32 = COPY $w2
167 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
168 ; CHECK: %select:gpr32 = CSINCWr %f, $wzr, 0, implicit $nzcv
169 ; CHECK: $w0 = COPY %select
170 ; CHECK: RET_ReallyLR implicit $w0
171 %reg0:gpr(s32) = COPY $w0
172 %reg1:gpr(s32) = COPY $w1
173 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
174 %cond:gpr(s1) = G_TRUNC %cmp(s32)
175 %t:gpr(s32) = G_CONSTANT i32 1
176 %f:gpr(s32) = COPY $w2
177 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
178 $w0 = COPY %select(s32)
179 RET_ReallyLR implicit $w0
184 regBankSelected: true
185 tracksRegLiveness: true
188 liveins: $w0, $w1, $w2
189 ; G_SELECT cc, -1, f -> CSINV f, zreg, inv_cc
191 ; CHECK-LABEL: name: csinv_t_neg_1
192 ; CHECK: liveins: $w0, $w1, $w2
193 ; CHECK: %reg0:gpr32 = COPY $w0
194 ; CHECK: %reg1:gpr32 = COPY $w1
195 ; CHECK: %f:gpr32 = COPY $w2
196 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
197 ; CHECK: %select:gpr32 = CSINVWr %f, $wzr, 0, implicit $nzcv
198 ; CHECK: $w0 = COPY %select
199 ; CHECK: RET_ReallyLR implicit $w0
200 %reg0:gpr(s32) = COPY $w0
201 %reg1:gpr(s32) = COPY $w1
202 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
203 %cond:gpr(s1) = G_TRUNC %cmp(s32)
204 %t:gpr(s32) = G_CONSTANT i32 -1
205 %f:gpr(s32) = COPY $w2
206 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
207 $w0 = COPY %select(s32)
208 RET_ReallyLR implicit $w0
213 regBankSelected: true
214 tracksRegLiveness: true
217 liveins: $w0, $w1, $w2
218 ; G_SELECT cc, t, 1 -> CSINC t, zreg, cc
220 ; CHECK-LABEL: name: csinc_f_1
221 ; CHECK: liveins: $w0, $w1, $w2
222 ; CHECK: %reg0:gpr32 = COPY $w0
223 ; CHECK: %reg1:gpr32 = COPY $w1
224 ; CHECK: %t:gpr32 = COPY $w2
225 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
226 ; CHECK: %select:gpr32 = CSINCWr %t, $wzr, 1, implicit $nzcv
227 ; CHECK: $w0 = COPY %select
228 ; CHECK: RET_ReallyLR implicit $w0
229 %reg0:gpr(s32) = COPY $w0
230 %reg1:gpr(s32) = COPY $w1
231 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
232 %cond:gpr(s1) = G_TRUNC %cmp(s32)
233 %t:gpr(s32) = COPY $w2
234 %f:gpr(s32) = G_CONSTANT i32 1
235 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
236 $w0 = COPY %select(s32)
237 RET_ReallyLR implicit $w0
242 regBankSelected: true
243 tracksRegLiveness: true
246 liveins: $w0, $w1, $w2
247 ; G_SELECT cc, t, -1 -> CSINC t, zreg, cc
249 ; CHECK-LABEL: name: csinc_f_neg_1
250 ; CHECK: liveins: $w0, $w1, $w2
251 ; CHECK: %reg0:gpr32 = COPY $w0
252 ; CHECK: %reg1:gpr32 = COPY $w1
253 ; CHECK: %t:gpr32 = COPY $w2
254 ; CHECK: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr %reg0, %reg1, implicit-def $nzcv
255 ; CHECK: %select:gpr32 = CSINVWr %t, $wzr, 1, implicit $nzcv
256 ; CHECK: $w0 = COPY %select
257 ; CHECK: RET_ReallyLR implicit $w0
258 %reg0:gpr(s32) = COPY $w0
259 %reg1:gpr(s32) = COPY $w1
260 %cmp:gpr(s32) = G_ICMP intpred(ne), %reg0(s32), %reg1
261 %cond:gpr(s1) = G_TRUNC %cmp(s32)
262 %t:gpr(s32) = COPY $w2
263 %f:gpr(s32) = G_CONSTANT i32 -1
264 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
265 $w0 = COPY %select(s32)
266 RET_ReallyLR implicit $w0
269 name: csinc_t_1_no_cmp
271 regBankSelected: true
272 tracksRegLiveness: true
276 ; G_SELECT cc, 1, f -> CSINC f, zreg, inv_cc
278 ; CHECK-LABEL: name: csinc_t_1_no_cmp
279 ; CHECK: liveins: $w0, $w1
280 ; CHECK: %reg0:gpr32 = COPY $w0
281 ; CHECK: %f:gpr32 = COPY $w1
282 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
283 ; CHECK: %select:gpr32 = CSINCWr %f, $wzr, 0, implicit $nzcv
284 ; CHECK: $w0 = COPY %select
285 ; CHECK: RET_ReallyLR implicit $w0
286 %reg0:gpr(s32) = COPY $w0
287 %cond:gpr(s1) = G_TRUNC %reg0(s32)
288 %t:gpr(s32) = G_CONSTANT i32 1
289 %f:gpr(s32) = COPY $w1
290 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
291 $w0 = COPY %select(s32)
292 RET_ReallyLR implicit $w0
296 name: csinc_f_1_no_cmp
298 regBankSelected: true
299 tracksRegLiveness: true
303 ; G_SELECT cc, t, 1 -> CSINC t, zreg, cc
305 ; CHECK-LABEL: name: csinc_f_1_no_cmp
306 ; CHECK: liveins: $w0, $w1
307 ; CHECK: %reg0:gpr32 = COPY $w0
308 ; CHECK: %t:gpr32 = COPY $w1
309 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
310 ; CHECK: %select:gpr32 = CSINCWr %t, $wzr, 1, implicit $nzcv
311 ; CHECK: $w0 = COPY %select
312 ; CHECK: RET_ReallyLR implicit $w0
313 %reg0:gpr(s32) = COPY $w0
314 %cond:gpr(s1) = G_TRUNC %reg0(s32)
315 %t:gpr(s32) = COPY $w1
316 %f:gpr(s32) = G_CONSTANT i32 1
317 %select:gpr(s32) = G_SELECT %cond(s1), %t, %f
318 $w0 = COPY %select(s32)
319 RET_ReallyLR implicit $w0
323 name: csinc_t_1_no_cmp_s64
325 regBankSelected: true
326 tracksRegLiveness: true
330 ; G_SELECT cc, 1, f -> CSINC f, zreg, inv_cc
332 ; CHECK-LABEL: name: csinc_t_1_no_cmp_s64
333 ; CHECK: liveins: $x0, $x1
334 ; CHECK: %reg0:gpr64 = COPY $x0
335 ; CHECK: %cond:gpr32 = COPY %reg0.sub_32
336 ; CHECK: %f:gpr64 = COPY $x1
337 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %cond, 0, implicit-def $nzcv
338 ; CHECK: %select:gpr64 = CSINCXr %f, $xzr, 0, implicit $nzcv
339 ; CHECK: $x0 = COPY %select
340 ; CHECK: RET_ReallyLR implicit $x0
341 %reg0:gpr(s64) = COPY $x0
342 %cond:gpr(s1) = G_TRUNC %reg0(s64)
343 %t:gpr(s64) = G_CONSTANT i64 1
344 %f:gpr(s64) = COPY $x1
345 %select:gpr(s64) = G_SELECT %cond(s1), %t, %f
346 $x0 = COPY %select(s64)
347 RET_ReallyLR implicit $x0
353 regBankSelected: true
354 tracksRegLiveness: true
357 liveins: $w0, $w1, $w2
358 ; G_SELECT cc, true, (G_SUB 0, x) -> CSNEG true, x, cc
360 ; CHECK-LABEL: name: csneg_s32
361 ; CHECK: liveins: $w0, $w1, $w2
362 ; CHECK: %reg0:gpr32 = COPY $w0
363 ; CHECK: %reg1:gpr32 = COPY $w1
364 ; CHECK: %t:gpr32 = COPY $w2
365 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
366 ; CHECK: %select:gpr32 = CSNEGWr %t, %reg1, 1, implicit $nzcv
367 ; CHECK: $w0 = COPY %select
368 ; CHECK: RET_ReallyLR implicit $w0
369 %reg0:gpr(s32) = COPY $w0
370 %cond:gpr(s1) = G_TRUNC %reg0(s32)
371 %reg1:gpr(s32) = COPY $w1
372 %t:gpr(s32) = COPY $w2
373 %zero:gpr(s32) = G_CONSTANT i32 0
374 %sub:gpr(s32) = G_SUB %zero(s32), %reg1
375 %select:gpr(s32) = G_SELECT %cond(s1), %t, %sub
376 $w0 = COPY %select(s32)
377 RET_ReallyLR implicit $w0
381 name: csneg_inverted_cc
383 regBankSelected: true
384 tracksRegLiveness: true
387 liveins: $w0, $w1, $w2
388 ; G_SELECT cc, (G_SUB 0, %x), %false -> CSNEG %x, %false, inv_cc
390 ; CHECK-LABEL: name: csneg_inverted_cc
391 ; CHECK: liveins: $w0, $w1, $w2
392 ; CHECK: %reg0:gpr32 = COPY $w0
393 ; CHECK: %reg1:gpr32 = COPY $w1
394 ; CHECK: %f:gpr32 = COPY $w2
395 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
396 ; CHECK: %select:gpr32 = CSNEGWr %f, %reg1, 0, implicit $nzcv
397 ; CHECK: $w0 = COPY %select
398 ; CHECK: RET_ReallyLR implicit $w0
399 %reg0:gpr(s32) = COPY $w0
400 %cond:gpr(s1) = G_TRUNC %reg0(s32)
401 %reg1:gpr(s32) = COPY $w1
402 %f:gpr(s32) = COPY $w2
403 %zero:gpr(s32) = G_CONSTANT i32 0
404 %sub:gpr(s32) = G_SUB %zero(s32), %reg1
405 %select:gpr(s32) = G_SELECT %cond(s1), %sub, %f
406 $w0 = COPY %select(s32)
407 RET_ReallyLR implicit $w0
413 regBankSelected: true
414 tracksRegLiveness: true
417 liveins: $x0, $x1, $x2
418 ; G_SELECT cc, true, (G_SUB 0, x) -> CSNEG true, x, cc
420 ; CHECK-LABEL: name: csneg_s64
421 ; CHECK: liveins: $x0, $x1, $x2
422 ; CHECK: %reg0:gpr64 = COPY $x0
423 ; CHECK: %cond:gpr32 = COPY %reg0.sub_32
424 ; CHECK: %reg1:gpr64 = COPY $x1
425 ; CHECK: %t:gpr64 = COPY $x2
426 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %cond, 0, implicit-def $nzcv
427 ; CHECK: %select:gpr64 = CSNEGXr %t, %reg1, 1, implicit $nzcv
428 ; CHECK: $x0 = COPY %select
429 ; CHECK: RET_ReallyLR implicit $x0
430 %reg0:gpr(s64) = COPY $x0
431 %cond:gpr(s1) = G_TRUNC %reg0(s64)
432 %reg1:gpr(s64) = COPY $x1
433 %t:gpr(s64) = COPY $x2
434 %zero:gpr(s64) = G_CONSTANT i64 0
435 %sub:gpr(s64) = G_SUB %zero(s64), %reg1
436 %select:gpr(s64) = G_SELECT %cond(s1), %t, %sub
437 $x0 = COPY %select(s64)
438 RET_ReallyLR implicit $x0
441 name: csneg_with_true_cst
443 regBankSelected: true
444 tracksRegLiveness: true
447 liveins: $w0, $w1, $w2
448 ; We should prefer eliminating the G_SUB over eliminating the constant true
451 ; CHECK-LABEL: name: csneg_with_true_cst
452 ; CHECK: liveins: $w0, $w1, $w2
453 ; CHECK: %reg0:gpr32 = COPY $w0
454 ; CHECK: %t:gpr32 = MOVi32imm 1
455 ; CHECK: %reg2:gpr32 = COPY $w2
456 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
457 ; CHECK: %select:gpr32 = CSNEGWr %t, %reg2, 1, implicit $nzcv
458 ; CHECK: $w0 = COPY %select
459 ; CHECK: RET_ReallyLR implicit $w0
460 %reg0:gpr(s32) = COPY $w0
461 %cond:gpr(s1) = G_TRUNC %reg0(s32)
462 %reg1:gpr(s32) = COPY $w1
463 %t:gpr(s32) = G_CONSTANT i32 1
464 %zero:gpr(s32) = G_CONSTANT i32 0
465 %reg2:gpr(s32) = COPY $w2
466 %sub:gpr(s32) = G_SUB %zero(s32), %reg2
467 %select:gpr(s32) = G_SELECT %cond(s1), %t, %sub
468 $w0 = COPY %select(s32)
469 RET_ReallyLR implicit $w0
474 regBankSelected: true
475 tracksRegLiveness: true
478 liveins: $w0, $w1, $w2
479 ; G_SELECT cc, true, (G_XOR x, -1) -> CSINV true, x, cc
481 ; CHECK-LABEL: name: csinv_s32
482 ; CHECK: liveins: $w0, $w1, $w2
483 ; CHECK: %reg0:gpr32 = COPY $w0
484 ; CHECK: %reg1:gpr32 = COPY $w1
485 ; CHECK: %t:gpr32 = COPY $w2
486 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
487 ; CHECK: %select:gpr32 = CSINVWr %t, %reg1, 1, implicit $nzcv
488 ; CHECK: $w0 = COPY %select
489 ; CHECK: RET_ReallyLR implicit $w0
490 %reg0:gpr(s32) = COPY $w0
491 %reg1:gpr(s32) = COPY $w1
492 %cond:gpr(s1) = G_TRUNC %reg0(s32)
493 %t:gpr(s32) = COPY $w2
494 %negative_one:gpr(s32) = G_CONSTANT i32 -1
495 %xor:gpr(s32) = G_XOR %reg1(s32), %negative_one
496 %select:gpr(s32) = G_SELECT %cond(s1), %t, %xor
497 $w0 = COPY %select(s32)
498 RET_ReallyLR implicit $w0
502 name: csinv_inverted_cc
504 regBankSelected: true
505 tracksRegLiveness: true
508 liveins: $w0, $w1, $w2
509 ; G_SELECT cc, (G_XOR x, -1), %false -> CSINV %x, %false, inv_cc
511 ; CHECK-LABEL: name: csinv_inverted_cc
512 ; CHECK: liveins: $w0, $w1, $w2
513 ; CHECK: %reg0:gpr32 = COPY $w0
514 ; CHECK: %reg1:gpr32 = COPY $w1
515 ; CHECK: %f:gpr32 = COPY $w2
516 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
517 ; CHECK: %select:gpr32 = CSINVWr %f, %reg1, 0, implicit $nzcv
518 ; CHECK: $w0 = COPY %select
519 ; CHECK: RET_ReallyLR implicit $w0
520 %reg0:gpr(s32) = COPY $w0
521 %reg1:gpr(s32) = COPY $w1
522 %cond:gpr(s1) = G_TRUNC %reg0(s32)
523 %f:gpr(s32) = COPY $w2
524 %negative_one:gpr(s32) = G_CONSTANT i32 -1
525 %xor:gpr(s32) = G_XOR %reg1(s32), %negative_one
526 %select:gpr(s32) = G_SELECT %cond(s1), %xor, %f
527 $w0 = COPY %select(s32)
528 RET_ReallyLR implicit $w0
534 regBankSelected: true
535 tracksRegLiveness: true
538 liveins: $x0, $x1, $x2
539 ; G_SELECT cc, true, (G_XOR x, -1) -> CSINV true, x, cc
541 ; CHECK-LABEL: name: csinv_s64
542 ; CHECK: liveins: $x0, $x1, $x2
543 ; CHECK: %reg0:gpr64 = COPY $x0
544 ; CHECK: %reg1:gpr64 = COPY $x1
545 ; CHECK: %cond:gpr32 = COPY %reg0.sub_32
546 ; CHECK: %t:gpr64 = COPY $x2
547 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %cond, 0, implicit-def $nzcv
548 ; CHECK: %select:gpr64 = CSINVXr %t, %reg1, 1, implicit $nzcv
549 ; CHECK: $x0 = COPY %select
550 ; CHECK: RET_ReallyLR implicit $x0
551 %reg0:gpr(s64) = COPY $x0
552 %reg1:gpr(s64) = COPY $x1
553 %cond:gpr(s1) = G_TRUNC %reg0(s64)
554 %t:gpr(s64) = COPY $x2
555 %negative_one:gpr(s64) = G_CONSTANT i64 -1
556 %xor:gpr(s64) = G_XOR %reg1(s64), %negative_one
557 %select:gpr(s64) = G_SELECT %cond(s1), %t, %xor
558 $x0 = COPY %select(s64)
559 RET_ReallyLR implicit $x0
563 name: xor_not_negative_one
565 regBankSelected: true
566 tracksRegLiveness: true
569 liveins: $x0, $x1, $x2
570 ; zext(s32 -1) != s64 -1, so we can't fold it away.
572 ; CHECK-LABEL: name: xor_not_negative_one
573 ; CHECK: liveins: $x0, $x1, $x2
574 ; CHECK: %reg0:gpr64 = COPY $x0
575 ; CHECK: %reg1:gpr64 = COPY $x1
576 ; CHECK: %cond:gpr32 = COPY %reg0.sub_32
577 ; CHECK: %t:gpr64 = COPY $x2
578 ; CHECK: %negative_one:gpr32 = MOVi32imm -1
579 ; CHECK: %zext:gpr64 = SUBREG_TO_REG 0, %negative_one, %subreg.sub_32
580 ; CHECK: %xor:gpr64 = EORXrr %reg1, %zext
581 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %cond, 0, implicit-def $nzcv
582 ; CHECK: %select:gpr64 = CSELXr %t, %xor, 1, implicit $nzcv
583 ; CHECK: $x0 = COPY %select
584 ; CHECK: RET_ReallyLR implicit $x0
585 %reg0:gpr(s64) = COPY $x0
586 %reg1:gpr(s64) = COPY $x1
587 %cond:gpr(s1) = G_TRUNC %reg0(s64)
588 %t:gpr(s64) = COPY $x2
589 %negative_one:gpr(s32) = G_CONSTANT i32 -1
590 %zext:gpr(s64) = G_ZEXT %negative_one(s32)
591 %xor:gpr(s64) = G_XOR %reg1(s64), %zext
592 %select:gpr(s64) = G_SELECT %cond(s1), %t, %xor
593 $x0 = COPY %select(s64)
594 RET_ReallyLR implicit $x0
600 regBankSelected: true
601 tracksRegLiveness: true
604 liveins: $w0, $w1, $w2
605 ; G_SELECT cc, %true, (G_ADD %x, 1) -> CSINC %true, %x, cc
606 ; CHECK-LABEL: name: csinc_s32
607 ; CHECK: liveins: $w0, $w1, $w2
608 ; CHECK: %reg0:gpr32 = COPY $w0
609 ; CHECK: %reg1:gpr32 = COPY $w1
610 ; CHECK: %t:gpr32 = COPY $w2
611 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
612 ; CHECK: %select:gpr32 = CSINCWr %t, %reg1, 1, implicit $nzcv
613 ; CHECK: $w0 = COPY %select
614 ; CHECK: RET_ReallyLR implicit $w0
615 %reg0:gpr(s32) = COPY $w0
616 %reg1:gpr(s32) = COPY $w1
617 %cond:gpr(s1) = G_TRUNC %reg0(s32)
618 %t:gpr(s32) = COPY $w2
619 %one:gpr(s32) = G_CONSTANT i32 1
620 %add:gpr(s32) = G_ADD %reg1(s32), %one
621 %select:gpr(s32) = G_SELECT %cond(s1), %t, %add
622 $w0 = COPY %select(s32)
623 RET_ReallyLR implicit $w0
627 name: csinc_s32_inverted_cc
629 regBankSelected: true
630 tracksRegLiveness: true
633 liveins: $w0, $w1, $w2
634 ; G_SELECT cc, (G_ADD %x, 1), %false -> CSINC %x, %false, inv_cc
635 ; CHECK-LABEL: name: csinc_s32_inverted_cc
636 ; CHECK: liveins: $w0, $w1, $w2
637 ; CHECK: %reg0:gpr32 = COPY $w0
638 ; CHECK: %reg1:gpr32 = COPY $w1
639 ; CHECK: %f:gpr32 = COPY $w2
640 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
641 ; CHECK: %select:gpr32 = CSINCWr %f, %reg1, 0, implicit $nzcv
642 ; CHECK: $w0 = COPY %select
643 ; CHECK: RET_ReallyLR implicit $w0
644 %reg0:gpr(s32) = COPY $w0
645 %reg1:gpr(s32) = COPY $w1
646 %cond:gpr(s1) = G_TRUNC %reg0(s32)
647 %f:gpr(s32) = COPY $w2
648 %one:gpr(s32) = G_CONSTANT i32 1
649 %add:gpr(s32) = G_ADD %reg1(s32), %one
650 %select:gpr(s32) = G_SELECT %cond(s1), %add, %f
651 $w0 = COPY %select(s32)
652 RET_ReallyLR implicit $w0
658 regBankSelected: true
659 tracksRegLiveness: true
662 liveins: $x0, $x1, $x2
663 ; G_SELECT cc, %true, (G_PTR_ADD %x, 1) -> CSINC %true, %x, cc
665 ; CHECK-LABEL: name: csinc_ptr_add
666 ; CHECK: liveins: $x0, $x1, $x2
667 ; CHECK: %reg0:gpr64 = COPY $x0
668 ; CHECK: %reg1:gpr64 = COPY $x1
669 ; CHECK: %cond:gpr32 = COPY %reg0.sub_32
670 ; CHECK: %t:gpr64 = COPY $x2
671 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %cond, 0, implicit-def $nzcv
672 ; CHECK: %select:gpr64 = CSINCXr %t, %reg1, 1, implicit $nzcv
673 ; CHECK: $x0 = COPY %select
674 ; CHECK: RET_ReallyLR implicit $x0
675 %reg0:gpr(s64) = COPY $x0
676 %reg1:gpr(p0) = COPY $x1
677 %cond:gpr(s1) = G_TRUNC %reg0(s64)
678 %t:gpr(p0) = COPY $x2
679 %one:gpr(s64) = G_CONSTANT i64 1
680 %ptr_add:gpr(p0) = G_PTR_ADD %reg1(p0), %one
681 %select:gpr(p0) = G_SELECT %cond(s1), %t, %ptr_add
682 $x0 = COPY %select(p0)
683 RET_ReallyLR implicit $x0
687 name: binop_dont_optimize_twice
689 regBankSelected: true
690 tracksRegLiveness: true
693 liveins: $w0, $w1, $w2
694 ; CHECK-LABEL: name: binop_dont_optimize_twice
695 ; CHECK: liveins: $w0, $w1, $w2
696 ; CHECK: %reg0:gpr32 = COPY $w0
697 ; CHECK: %reg1:gpr32 = COPY $w1
698 ; CHECK: %reg2:gpr32 = COPY $w2
699 ; CHECK: %xor:gpr32 = ORNWrr $wzr, %reg1
700 ; CHECK: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri %reg0, 0, implicit-def $nzcv
701 ; CHECK: %select:gpr32 = CSNEGWr %xor, %reg2, 1, implicit $nzcv
702 ; CHECK: $w0 = COPY %select
703 ; CHECK: RET_ReallyLR implicit $w0
704 %reg0:gpr(s32) = COPY $w0
705 %reg1:gpr(s32) = COPY $w1
706 %reg2:gpr(s32) = COPY $w2
707 %cond:gpr(s1) = G_TRUNC %reg0(s32)
708 %f:gpr(s32) = COPY $w2
709 %negative_one:gpr(s32) = G_CONSTANT i32 -1
710 %xor:gpr(s32) = G_XOR %reg1(s32), %negative_one
711 %zero:gpr(s32) = G_CONSTANT i32 0
712 %sub:gpr(s32) = G_SUB %zero(s32), %reg2
713 %select:gpr(s32) = G_SELECT %cond(s1), %xor, %sub
714 $w0 = COPY %select(s32)
715 RET_ReallyLR implicit $w0