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 that we can fold compares into integer selects.
6 # This is an integer version of fold-fp-select.mir.
15 tracksRegLiveness: true
20 ; CHECK-LABEL: name: eq
21 ; CHECK: liveins: $w0, $w1
23 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32sp = COPY $w0
24 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
25 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
26 ; CHECK-NEXT: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 0, 0, implicit-def $nzcv
27 ; CHECK-NEXT: [[CSELWr:%[0-9]+]]:gpr32 = CSELWr [[COPY2]], [[COPY1]], 0, implicit $nzcv
28 ; CHECK-NEXT: $w0 = COPY [[CSELWr]]
29 ; CHECK-NEXT: RET_ReallyLR implicit $w0
30 %0:gpr(s32) = COPY $w0
31 %1:gpr(s32) = COPY $w1
32 %2:gpr(s32) = G_CONSTANT i32 0
33 %5:gpr(s32) = G_ICMP intpred(eq), %0(s32), %2
34 %4:gpr(s32) = G_SELECT %5, %2, %1
36 RET_ReallyLR implicit $w0
44 tracksRegLiveness: true
47 liveins: $s0, $w0, $w1
49 ; CHECK-LABEL: name: using_fcmp
50 ; CHECK: liveins: $s0, $w0, $w1
52 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w1
53 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:fpr32 = COPY $s0
54 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
55 ; CHECK-NEXT: nofpexcept FCMPSri [[COPY1]], implicit-def $nzcv
56 ; CHECK-NEXT: [[CSELWr:%[0-9]+]]:gpr32 = CSELWr [[COPY2]], [[COPY]], 0, implicit $nzcv
57 ; CHECK-NEXT: $w0 = COPY [[CSELWr]]
58 ; CHECK-NEXT: RET_ReallyLR implicit $w0
59 %1:gpr(s32) = COPY $w1
60 %2:fpr(s32) = COPY $s0
61 %3:fpr(s32) = G_FCONSTANT float 0.000000e+00
62 %6:gpr(s32) = G_CONSTANT i32 0
63 %7:gpr(s32) = G_FCMP floatpred(oeq), %2(s32), %3
64 %5:gpr(s32) = G_SELECT %7, %6, %1
66 RET_ReallyLR implicit $w0
74 tracksRegLiveness: true
79 ; CHECK-LABEL: name: csinc
80 ; CHECK: liveins: $w0, $w1
82 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32common = COPY $w0
83 ; CHECK-NEXT: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri [[COPY]], 1, 0, implicit-def $nzcv
84 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr [[COPY]], $wzr, 0, implicit $nzcv
85 ; CHECK-NEXT: $w0 = COPY [[CSINCWr]]
86 ; CHECK-NEXT: RET_ReallyLR implicit $w0
87 %0:gpr(s32) = COPY $w0
88 %1:gpr(s32) = COPY $w1
89 %2:gpr(s32) = G_CONSTANT i32 1
90 %5:gpr(s32) = G_ICMP intpred(eq), %0(s32), %2
91 %4:gpr(s32) = G_SELECT %5, %0, %2
93 RET_ReallyLR implicit $w0