1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-unknown-unknown -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
4 # Test that we can produce a TBNZ when we have a slt compare against 0.
6 # The bit tested should be the size of the test register minus 1.
16 ; CHECK-LABEL: name: tbnzx_slt
18 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
20 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
21 ; CHECK-NEXT: TBNZX %copy, 63, %bb.1
25 ; CHECK-NEXT: RET_ReallyLR
27 successors: %bb.0, %bb.1
29 %copy:gpr(s64) = COPY $x0
30 %zero:gpr(s64) = G_CONSTANT i64 0
31 %cmp:gpr(s32) = G_ICMP intpred(slt), %copy(s64), %zero
32 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
33 G_BRCOND %cmp_trunc(s1), %bb.1
45 ; CHECK-LABEL: name: tbnzw_slt
47 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
49 ; CHECK-NEXT: %copy:gpr32 = COPY $w0
50 ; CHECK-NEXT: TBNZW %copy, 31, %bb.1
54 ; CHECK-NEXT: RET_ReallyLR
56 successors: %bb.0, %bb.1
58 %copy:gpr(s32) = COPY $w0
59 %zero:gpr(s32) = G_CONSTANT i32 0
60 %cmp:gpr(s32) = G_ICMP intpred(slt), %copy(s32), %zero
61 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
62 G_BRCOND %cmp_trunc(s1), %bb.1
69 name: no_tbnz_not_zero
74 ; CHECK-LABEL: name: no_tbnz_not_zero
76 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
78 ; CHECK-NEXT: %copy:gpr32sp = COPY $w0
79 ; CHECK-NEXT: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri %copy, 1, 0, implicit-def $nzcv
80 ; CHECK-NEXT: Bcc 11, %bb.1, implicit $nzcv
84 ; CHECK-NEXT: RET_ReallyLR
86 successors: %bb.0, %bb.1
88 %copy:gpr(s32) = COPY $w0
89 %one:gpr(s32) = G_CONSTANT i32 1
90 %cmp:gpr(s32) = G_ICMP intpred(slt), %copy(s32), %one
91 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
92 G_BRCOND %cmp_trunc(s1), %bb.1
102 regBankSelected: true
104 ; CHECK-LABEL: name: dont_fold_and
106 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
108 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
109 ; CHECK-NEXT: [[ANDSXri:%[0-9]+]]:gpr64 = ANDSXri %copy, 8000, implicit-def $nzcv
110 ; CHECK-NEXT: Bcc 11, %bb.1, implicit $nzcv
111 ; CHECK-NEXT: B %bb.0
114 ; CHECK-NEXT: RET_ReallyLR
116 successors: %bb.0, %bb.1
118 %copy:gpr(s64) = COPY $x0
119 %bit:gpr(s64) = G_CONSTANT i64 8
120 %zero:gpr(s64) = G_CONSTANT i64 0
121 %c:gpr(s64) = G_CONSTANT i64 8
122 %and:gpr(s64) = G_AND %copy, %bit
123 %cmp:gpr(s32) = G_ICMP intpred(slt), %and(s64), %zero
124 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
125 G_BRCOND %cmp_trunc(s1), %bb.1
135 regBankSelected: true
137 ; CHECK-LABEL: name: dont_commute
139 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
141 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
142 ; CHECK-NEXT: %zero:gpr64 = COPY $xzr
143 ; CHECK-NEXT: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr %zero, %copy, implicit-def $nzcv
144 ; CHECK-NEXT: Bcc 11, %bb.1, implicit $nzcv
145 ; CHECK-NEXT: B %bb.0
148 ; CHECK-NEXT: RET_ReallyLR
150 successors: %bb.0, %bb.1
152 %copy:gpr(s64) = COPY $x0
153 %zero:gpr(s64) = G_CONSTANT i64 0
154 %cmp:gpr(s32) = G_ICMP intpred(slt), %zero, %copy(s64)
155 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
156 G_BRCOND %cmp_trunc(s1), %bb.1