1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi %s -verify-machineinstrs -o - | FileCheck %s
4 define i32 @csinc_const_65(i32 %a) {
5 ; CHECK-LABEL: csinc_const_65:
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: movs r1, #5
8 ; CHECK-NEXT: cmp r0, #45
9 ; CHECK-NEXT: cinc r0, r1, gt
12 %cmp = icmp sgt i32 %a, 45
13 %spec.select = select i1 %cmp, i32 6, i32 5
17 define i32 @csinc_const_56(i32 %a) {
18 ; CHECK-LABEL: csinc_const_56:
19 ; CHECK: @ %bb.0: @ %entry
20 ; CHECK-NEXT: movs r1, #5
21 ; CHECK-NEXT: cmp r0, #45
22 ; CHECK-NEXT: cinc r0, r1, le
25 %cmp = icmp sgt i32 %a, 45
26 %spec.select = select i1 %cmp, i32 5, i32 6
30 define i32 @csinc_const_zext(i32 %a) {
31 ; CHECK-LABEL: csinc_const_zext:
32 ; CHECK: @ %bb.0: @ %entry
33 ; CHECK-NEXT: cmp r0, #45
34 ; CHECK-NEXT: cset r0, gt
37 %cmp = icmp sgt i32 %a, 45
38 %spec.select = zext i1 %cmp to i32
42 define i32 @csinv_const_56(i32 %a) {
43 ; CHECK-LABEL: csinv_const_56:
44 ; CHECK: @ %bb.0: @ %entry
45 ; CHECK-NEXT: movs r1, #5
46 ; CHECK-NEXT: cmp r0, #45
47 ; CHECK-NEXT: cinv r0, r1, gt
50 %cmp = icmp sgt i32 %a, 45
51 %spec.select = select i1 %cmp, i32 -6, i32 5
55 define i32 @csinv_const_65(i32 %a) {
56 ; CHECK-LABEL: csinv_const_65:
57 ; CHECK: @ %bb.0: @ %entry
58 ; CHECK-NEXT: movs r1, #5
59 ; CHECK-NEXT: cmp r0, #45
60 ; CHECK-NEXT: cinv r0, r1, le
63 %cmp = icmp sgt i32 %a, 45
64 %spec.select = select i1 %cmp, i32 5, i32 -6
68 define i32 @csinv_const_sext(i32 %a) {
69 ; CHECK-LABEL: csinv_const_sext:
70 ; CHECK: @ %bb.0: @ %entry
71 ; CHECK-NEXT: cmp r0, #45
72 ; CHECK-NEXT: csetm r0, gt
75 %cmp = icmp sgt i32 %a, 45
76 %spec.select = sext i1 %cmp to i32
80 define i32 @csneg_const(i32 %a) {
81 ; CHECK-LABEL: csneg_const:
82 ; CHECK: @ %bb.0: @ %entry
83 ; CHECK-NEXT: movs r1, #1
84 ; CHECK-NEXT: cmp r0, #45
85 ; CHECK-NEXT: cneg r0, r1, le
88 %cmp = icmp sgt i32 %a, 45
89 %spec.select = select i1 %cmp, i32 1, i32 -1
93 define i32 @csneg_const_r(i32 %a) {
94 ; CHECK-LABEL: csneg_const_r:
95 ; CHECK: @ %bb.0: @ %entry
96 ; CHECK-NEXT: movs r1, #1
97 ; CHECK-NEXT: cmp r0, #45
98 ; CHECK-NEXT: cneg r0, r1, gt
101 %cmp = icmp sgt i32 %a, 45
102 %spec.select = select i1 %cmp, i32 -1, i32 1
106 define i32 @csel_var(i32 %a, i32 %b, i32 %c) {
107 ; CHECK-LABEL: csel_var:
108 ; CHECK: @ %bb.0: @ %entry
109 ; CHECK-NEXT: cmp r0, #45
111 ; CHECK-NEXT: movle r1, r2
112 ; CHECK-NEXT: mov r0, r1
115 %cmp = icmp sgt i32 %a, 45
116 %spec.select = select i1 %cmp, i32 %b, i32 %c
120 define i32 @csinc_var(i32 %a, i32 %b, i32 %c) {
121 ; CHECK-LABEL: csinc_var:
122 ; CHECK: @ %bb.0: @ %entry
123 ; CHECK-NEXT: cmp r0, #45
124 ; CHECK-NEXT: csinc r0, r1, r2, gt
127 %cmp = icmp sgt i32 %a, 45
128 %cplus1 = add nsw i32 %c, 1
129 %spec.select = select i1 %cmp, i32 %b, i32 %cplus1
133 define i32 @csinc_swap_var(i32 %a, i32 %b, i32 %c) {
134 ; CHECK-LABEL: csinc_swap_var:
135 ; CHECK: @ %bb.0: @ %entry
136 ; CHECK-NEXT: cmp r0, #45
137 ; CHECK-NEXT: csinc r0, r2, r1, le
140 %cmp = icmp sgt i32 %a, 45
141 %bplus1 = add nsw i32 %b, 1
142 %spec.select = select i1 %cmp, i32 %bplus1, i32 %c
146 define i32 @csinv_var(i32 %a, i32 %b, i32 %c) {
147 ; CHECK-LABEL: csinv_var:
148 ; CHECK: @ %bb.0: @ %entry
149 ; CHECK-NEXT: cmp r0, #45
150 ; CHECK-NEXT: csinv r0, r1, r2, gt
153 %cmp = icmp sgt i32 %a, 45
154 %cinv = xor i32 %c, -1
155 %spec.select = select i1 %cmp, i32 %b, i32 %cinv
159 define i32 @csinv_swap_var(i32 %a, i32 %b, i32 %c) {
160 ; CHECK-LABEL: csinv_swap_var:
161 ; CHECK: @ %bb.0: @ %entry
162 ; CHECK-NEXT: cmp r0, #45
163 ; CHECK-NEXT: csinv r0, r2, r1, le
166 %cmp = icmp sgt i32 %a, 45
167 %binv = xor i32 %b, -1
168 %spec.select = select i1 %cmp, i32 %binv, i32 %c
172 define i32 @csneg_var(i32 %a, i32 %b, i32 %c) {
173 ; CHECK-LABEL: csneg_var:
174 ; CHECK: @ %bb.0: @ %entry
175 ; CHECK-NEXT: cmp r0, #45
176 ; CHECK-NEXT: csneg r0, r1, r2, gt
179 %cmp = icmp sgt i32 %a, 45
180 %cneg = sub i32 0, %c
181 %spec.select = select i1 %cmp, i32 %b, i32 %cneg
185 define i32 @csneg_swap_var_sgt(i32 %a, i32 %b, i32 %c) {
186 ; CHECK-LABEL: csneg_swap_var_sgt:
187 ; CHECK: @ %bb.0: @ %entry
188 ; CHECK-NEXT: cmp r0, #45
189 ; CHECK-NEXT: csneg r0, r2, r1, le
192 %cmp = icmp sgt i32 %a, 45
193 %bneg = sub i32 0, %b
194 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
198 define i32 @csneg_swap_var_sge(i32 %a, i32 %b, i32 %c) {
199 ; CHECK-LABEL: csneg_swap_var_sge:
200 ; CHECK: @ %bb.0: @ %entry
201 ; CHECK-NEXT: cmp r0, #44
202 ; CHECK-NEXT: csneg r0, r2, r1, le
205 %cmp = icmp sge i32 %a, 45
206 %bneg = sub i32 0, %b
207 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
211 define i32 @csneg_swap_var_sle(i32 %a, i32 %b, i32 %c) {
212 ; CHECK-LABEL: csneg_swap_var_sle:
213 ; CHECK: @ %bb.0: @ %entry
214 ; CHECK-NEXT: cmp r0, #46
215 ; CHECK-NEXT: csneg r0, r2, r1, ge
218 %cmp = icmp sle i32 %a, 45
219 %bneg = sub i32 0, %b
220 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
224 define i32 @csneg_swap_var_slt(i32 %a, i32 %b, i32 %c) {
225 ; CHECK-LABEL: csneg_swap_var_slt:
226 ; CHECK: @ %bb.0: @ %entry
227 ; CHECK-NEXT: cmp r0, #45
228 ; CHECK-NEXT: csneg r0, r2, r1, ge
231 %cmp = icmp slt i32 %a, 45
232 %bneg = sub i32 0, %b
233 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
237 define i32 @csneg_swap_var_ugt(i32 %a, i32 %b, i32 %c) {
238 ; CHECK-LABEL: csneg_swap_var_ugt:
239 ; CHECK: @ %bb.0: @ %entry
240 ; CHECK-NEXT: cmp r0, #45
241 ; CHECK-NEXT: csneg r0, r2, r1, ls
244 %cmp = icmp ugt i32 %a, 45
245 %bneg = sub i32 0, %b
246 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
250 define i32 @csneg_swap_var_uge(i32 %a, i32 %b, i32 %c) {
251 ; CHECK-LABEL: csneg_swap_var_uge:
252 ; CHECK: @ %bb.0: @ %entry
253 ; CHECK-NEXT: cmp r0, #44
254 ; CHECK-NEXT: csneg r0, r2, r1, ls
257 %cmp = icmp uge i32 %a, 45
258 %bneg = sub i32 0, %b
259 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
263 define i32 @csneg_swap_var_ule(i32 %a, i32 %b, i32 %c) {
264 ; CHECK-LABEL: csneg_swap_var_ule:
265 ; CHECK: @ %bb.0: @ %entry
266 ; CHECK-NEXT: cmp r0, #46
267 ; CHECK-NEXT: csneg r0, r2, r1, hs
270 %cmp = icmp ule i32 %a, 45
271 %bneg = sub i32 0, %b
272 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
276 define i32 @csneg_swap_var_ult(i32 %a, i32 %b, i32 %c) {
277 ; CHECK-LABEL: csneg_swap_var_ult:
278 ; CHECK: @ %bb.0: @ %entry
279 ; CHECK-NEXT: cmp r0, #45
280 ; CHECK-NEXT: csneg r0, r2, r1, hs
283 %cmp = icmp ult i32 %a, 45
284 %bneg = sub i32 0, %b
285 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
289 define i32 @csneg_swap_var_ne(i32 %a, i32 %b, i32 %c) {
290 ; CHECK-LABEL: csneg_swap_var_ne:
291 ; CHECK: @ %bb.0: @ %entry
292 ; CHECK-NEXT: cmp r0, #45
293 ; CHECK-NEXT: csneg r0, r2, r1, ne
296 %cmp = icmp eq i32 %a, 45
297 %bneg = sub i32 0, %b
298 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
302 define i32 @csneg_swap_var_eq(i32 %a, i32 %b, i32 %c) {
303 ; CHECK-LABEL: csneg_swap_var_eq:
304 ; CHECK: @ %bb.0: @ %entry
305 ; CHECK-NEXT: cmp r0, #45
306 ; CHECK-NEXT: csneg r0, r2, r1, eq
309 %cmp = icmp ne i32 %a, 45
310 %bneg = sub i32 0, %b
311 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
315 define i32 @csinc_inplace(i32 %a, i32 %b) {
316 ; CHECK-LABEL: csinc_inplace:
317 ; CHECK: @ %bb.0: @ %entry
318 ; CHECK-NEXT: cmp r1, #45
319 ; CHECK-NEXT: cinc r0, r0, gt
322 %cmp = icmp sgt i32 %b, 45
323 %inc = zext i1 %cmp to i32
324 %spec.select = add nsw i32 %inc, %a
328 define i32 @csinv_inplace(i32 %a, i32 %b) {
329 ; CHECK-LABEL: csinv_inplace:
330 ; CHECK: @ %bb.0: @ %entry
331 ; CHECK-NEXT: cmp r1, #45
332 ; CHECK-NEXT: cinv r0, r0, gt
335 %cmp = icmp sgt i32 %b, 45
336 %sub = sext i1 %cmp to i32
337 %xor = xor i32 %sub, %a