1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv8.1m.main-none-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
110 ; CHECK-NEXT: csel r0, r1, r2, gt
113 %cmp = icmp sgt i32 %a, 45
114 %spec.select = select i1 %cmp, i32 %b, i32 %c
118 define i32 @csinc_var(i32 %a, i32 %b, i32 %c) {
119 ; CHECK-LABEL: csinc_var:
120 ; CHECK: @ %bb.0: @ %entry
121 ; CHECK-NEXT: cmp r0, #45
122 ; CHECK-NEXT: csinc r0, r1, r2, gt
125 %cmp = icmp sgt i32 %a, 45
126 %cplus1 = add nsw i32 %c, 1
127 %spec.select = select i1 %cmp, i32 %b, i32 %cplus1
131 define i32 @csinc_swap_var(i32 %a, i32 %b, i32 %c) {
132 ; CHECK-LABEL: csinc_swap_var:
133 ; CHECK: @ %bb.0: @ %entry
134 ; CHECK-NEXT: cmp r0, #45
135 ; CHECK-NEXT: csinc r0, r2, r1, le
138 %cmp = icmp sgt i32 %a, 45
139 %bplus1 = add nsw i32 %b, 1
140 %spec.select = select i1 %cmp, i32 %bplus1, i32 %c
144 define i32 @csinv_var(i32 %a, i32 %b, i32 %c) {
145 ; CHECK-LABEL: csinv_var:
146 ; CHECK: @ %bb.0: @ %entry
147 ; CHECK-NEXT: cmp r0, #45
148 ; CHECK-NEXT: csinv r0, r1, r2, gt
151 %cmp = icmp sgt i32 %a, 45
152 %cinv = xor i32 %c, -1
153 %spec.select = select i1 %cmp, i32 %b, i32 %cinv
157 define i32 @csinv_swap_var(i32 %a, i32 %b, i32 %c) {
158 ; CHECK-LABEL: csinv_swap_var:
159 ; CHECK: @ %bb.0: @ %entry
160 ; CHECK-NEXT: cmp r0, #45
161 ; CHECK-NEXT: csinv r0, r2, r1, le
164 %cmp = icmp sgt i32 %a, 45
165 %binv = xor i32 %b, -1
166 %spec.select = select i1 %cmp, i32 %binv, i32 %c
170 define i32 @csneg_var(i32 %a, i32 %b, i32 %c) {
171 ; CHECK-LABEL: csneg_var:
172 ; CHECK: @ %bb.0: @ %entry
173 ; CHECK-NEXT: cmp r0, #45
174 ; CHECK-NEXT: csneg r0, r1, r2, gt
177 %cmp = icmp sgt i32 %a, 45
178 %cneg = sub i32 0, %c
179 %spec.select = select i1 %cmp, i32 %b, i32 %cneg
183 define i32 @csneg_swap_var_sgt(i32 %a, i32 %b, i32 %c) {
184 ; CHECK-LABEL: csneg_swap_var_sgt:
185 ; CHECK: @ %bb.0: @ %entry
186 ; CHECK-NEXT: cmp r0, #45
187 ; CHECK-NEXT: csneg r0, r2, r1, le
190 %cmp = icmp sgt i32 %a, 45
191 %bneg = sub i32 0, %b
192 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
196 define i32 @csneg_swap_var_sge(i32 %a, i32 %b, i32 %c) {
197 ; CHECK-LABEL: csneg_swap_var_sge:
198 ; CHECK: @ %bb.0: @ %entry
199 ; CHECK-NEXT: cmp r0, #44
200 ; CHECK-NEXT: csneg r0, r2, r1, le
203 %cmp = icmp sge i32 %a, 45
204 %bneg = sub i32 0, %b
205 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
209 define i32 @csneg_swap_var_sle(i32 %a, i32 %b, i32 %c) {
210 ; CHECK-LABEL: csneg_swap_var_sle:
211 ; CHECK: @ %bb.0: @ %entry
212 ; CHECK-NEXT: cmp r0, #46
213 ; CHECK-NEXT: csneg r0, r2, r1, ge
216 %cmp = icmp sle i32 %a, 45
217 %bneg = sub i32 0, %b
218 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
222 define i32 @csneg_swap_var_slt(i32 %a, i32 %b, i32 %c) {
223 ; CHECK-LABEL: csneg_swap_var_slt:
224 ; CHECK: @ %bb.0: @ %entry
225 ; CHECK-NEXT: cmp r0, #45
226 ; CHECK-NEXT: csneg r0, r2, r1, ge
229 %cmp = icmp slt i32 %a, 45
230 %bneg = sub i32 0, %b
231 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
235 define i32 @csneg_swap_var_ugt(i32 %a, i32 %b, i32 %c) {
236 ; CHECK-LABEL: csneg_swap_var_ugt:
237 ; CHECK: @ %bb.0: @ %entry
238 ; CHECK-NEXT: cmp r0, #45
239 ; CHECK-NEXT: csneg r0, r2, r1, ls
242 %cmp = icmp ugt i32 %a, 45
243 %bneg = sub i32 0, %b
244 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
248 define i32 @csneg_swap_var_uge(i32 %a, i32 %b, i32 %c) {
249 ; CHECK-LABEL: csneg_swap_var_uge:
250 ; CHECK: @ %bb.0: @ %entry
251 ; CHECK-NEXT: cmp r0, #44
252 ; CHECK-NEXT: csneg r0, r2, r1, ls
255 %cmp = icmp uge i32 %a, 45
256 %bneg = sub i32 0, %b
257 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
261 define i32 @csneg_swap_var_ule(i32 %a, i32 %b, i32 %c) {
262 ; CHECK-LABEL: csneg_swap_var_ule:
263 ; CHECK: @ %bb.0: @ %entry
264 ; CHECK-NEXT: cmp r0, #46
265 ; CHECK-NEXT: csneg r0, r2, r1, hs
268 %cmp = icmp ule i32 %a, 45
269 %bneg = sub i32 0, %b
270 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
274 define i32 @csneg_swap_var_ult(i32 %a, i32 %b, i32 %c) {
275 ; CHECK-LABEL: csneg_swap_var_ult:
276 ; CHECK: @ %bb.0: @ %entry
277 ; CHECK-NEXT: cmp r0, #45
278 ; CHECK-NEXT: csneg r0, r2, r1, hs
281 %cmp = icmp ult i32 %a, 45
282 %bneg = sub i32 0, %b
283 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
287 define i32 @csneg_swap_var_ne(i32 %a, i32 %b, i32 %c) {
288 ; CHECK-LABEL: csneg_swap_var_ne:
289 ; CHECK: @ %bb.0: @ %entry
290 ; CHECK-NEXT: cmp r0, #45
291 ; CHECK-NEXT: csneg r0, r2, r1, ne
294 %cmp = icmp eq i32 %a, 45
295 %bneg = sub i32 0, %b
296 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
300 define i32 @csneg_swap_var_eq(i32 %a, i32 %b, i32 %c) {
301 ; CHECK-LABEL: csneg_swap_var_eq:
302 ; CHECK: @ %bb.0: @ %entry
303 ; CHECK-NEXT: cmp r0, #45
304 ; CHECK-NEXT: csneg r0, r2, r1, eq
307 %cmp = icmp ne i32 %a, 45
308 %bneg = sub i32 0, %b
309 %spec.select = select i1 %cmp, i32 %bneg, i32 %c
313 define i32 @csinc_inplace(i32 %a, i32 %b) {
314 ; CHECK-LABEL: csinc_inplace:
315 ; CHECK: @ %bb.0: @ %entry
316 ; CHECK-NEXT: cmp r1, #45
317 ; CHECK-NEXT: cinc r0, r0, gt
320 %cmp = icmp sgt i32 %b, 45
321 %inc = zext i1 %cmp to i32
322 %spec.select = add nsw i32 %inc, %a
326 define i32 @csinv_inplace(i32 %a, i32 %b) {
327 ; CHECK-LABEL: csinv_inplace:
328 ; CHECK: @ %bb.0: @ %entry
329 ; CHECK-NEXT: cmp r1, #45
330 ; CHECK-NEXT: cinv r0, r0, gt
333 %cmp = icmp sgt i32 %b, 45
334 %sub = sext i1 %cmp to i32
335 %xor = xor i32 %sub, %a
339 define i32 @csinc_to_csinv(i32 %a) {
340 ; CHECK-LABEL: csinc_to_csinv:
341 ; CHECK: @ %bb.0: @ %entry
342 ; CHECK-NEXT: cmp r0, #46
343 ; CHECK-NEXT: csetm r0, lt
346 %cmp = icmp sgt i32 %a, 45
347 %spec.select = select i1 %cmp, i32 0, i32 1
348 %s = sub i32 0, %spec.select
352 define i32 @csinc_to_csinv_multi(i32 %a) {
353 ; CHECK-LABEL: csinc_to_csinv_multi:
354 ; CHECK: @ %bb.0: @ %entry
355 ; CHECK-NEXT: cmp r0, #46
356 ; CHECK-NEXT: cset r0, lt
357 ; CHECK-NEXT: rsbs r1, r0, #0
358 ; CHECK-NEXT: eors r0, r1
361 %cmp = icmp sgt i32 %a, 45
362 %spec.select = select i1 %cmp, i32 0, i32 1
363 %s = sub i32 0, %spec.select
364 %t = xor i32 %s, %spec.select