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)
19 ; CHECK-NEXT: liveins: $x0
21 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
22 ; CHECK-NEXT: TBNZX %copy, 63, %bb.1
26 ; CHECK-NEXT: RET_ReallyLR
28 successors: %bb.0, %bb.1
30 %copy:gpr(s64) = COPY $x0
31 %zero:gpr(s64) = G_CONSTANT i64 0
32 %cmp:gpr(s32) = G_ICMP intpred(slt), %copy(s64), %zero
45 ; CHECK-LABEL: name: tbnzw_slt
47 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
48 ; CHECK-NEXT: liveins: $x0
50 ; CHECK-NEXT: %copy:gpr32 = COPY $w0
51 ; CHECK-NEXT: TBNZW %copy, 31, %bb.1
55 ; CHECK-NEXT: RET_ReallyLR
57 successors: %bb.0, %bb.1
59 %copy:gpr(s32) = COPY $w0
60 %zero:gpr(s32) = G_CONSTANT i32 0
61 %cmp:gpr(s32) = G_ICMP intpred(slt), %copy(s32), %zero
74 ; CHECK-LABEL: name: tbnzx_sge
76 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
77 ; CHECK-NEXT: liveins: $x0
79 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
80 ; CHECK-NEXT: TBZX %copy, 63, %bb.1
84 ; CHECK-NEXT: RET_ReallyLR
86 successors: %bb.0, %bb.1
88 %copy:gpr(s64) = COPY $x0
89 %zero:gpr(s64) = G_CONSTANT i64 0
90 %cmp:gpr(s32) = G_ICMP intpred(sge), %copy(s64), %zero
101 regBankSelected: true
103 ; CHECK-LABEL: name: tbnzw_sge
105 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
106 ; CHECK-NEXT: liveins: $x0
108 ; CHECK-NEXT: %copy:gpr32 = COPY $w0
109 ; CHECK-NEXT: TBZW %copy, 31, %bb.1
110 ; CHECK-NEXT: B %bb.0
113 ; CHECK-NEXT: RET_ReallyLR
115 successors: %bb.0, %bb.1
117 %copy:gpr(s32) = COPY $w0
118 %zero:gpr(s32) = G_CONSTANT i32 0
119 %cmp:gpr(s32) = G_ICMP intpred(sge), %copy(s32), %zero
127 name: no_tbnz_not_zero
130 regBankSelected: true
132 ; CHECK-LABEL: name: no_tbnz_not_zero
134 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
135 ; CHECK-NEXT: liveins: $x0
137 ; CHECK-NEXT: %copy:gpr32sp = COPY $w0
138 ; CHECK-NEXT: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri %copy, 1, 0, implicit-def $nzcv
139 ; CHECK-NEXT: Bcc 11, %bb.1, implicit $nzcv
140 ; CHECK-NEXT: B %bb.0
143 ; CHECK-NEXT: RET_ReallyLR
145 successors: %bb.0, %bb.1
147 %copy:gpr(s32) = COPY $w0
148 %one:gpr(s32) = G_CONSTANT i32 1
149 %cmp:gpr(s32) = G_ICMP intpred(slt), %copy(s32), %one
160 regBankSelected: true
162 ; CHECK-LABEL: name: dont_fold_and
164 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
165 ; CHECK-NEXT: liveins: $x0
167 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
168 ; CHECK-NEXT: [[ANDSXri:%[0-9]+]]:gpr64 = ANDSXri %copy, 8000, implicit-def $nzcv
169 ; CHECK-NEXT: Bcc 11, %bb.1, implicit $nzcv
170 ; CHECK-NEXT: B %bb.0
173 ; CHECK-NEXT: RET_ReallyLR
175 successors: %bb.0, %bb.1
177 %copy:gpr(s64) = COPY $x0
178 %bit:gpr(s64) = G_CONSTANT i64 8
179 %zero:gpr(s64) = G_CONSTANT i64 0
180 %c:gpr(s64) = G_CONSTANT i64 8
181 %and:gpr(s64) = G_AND %copy, %bit
182 %cmp:gpr(s32) = G_ICMP intpred(slt), %and(s64), %zero
193 regBankSelected: true
195 ; CHECK-LABEL: name: dont_commute
197 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
198 ; CHECK-NEXT: liveins: $x0
200 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
201 ; CHECK-NEXT: %zero:gpr64 = COPY $xzr
202 ; CHECK-NEXT: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr %zero, %copy, implicit-def $nzcv
203 ; CHECK-NEXT: Bcc 11, %bb.1, implicit $nzcv
204 ; CHECK-NEXT: B %bb.0
207 ; CHECK-NEXT: RET_ReallyLR
209 successors: %bb.0, %bb.1
211 %copy:gpr(s64) = COPY $x0
212 %zero:gpr(s64) = G_CONSTANT i64 0
213 %cmp:gpr(s32) = G_ICMP intpred(slt), %zero, %copy(s64)