1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=armv7a-none-none-eabi -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK7A
3 ; RUN: llc -mtriple=thumbv6m-none-none-eabi -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK6M
4 ; RUN: llc -mtriple=thumbv7m-none-none-eabi -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK7M
5 ; RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK81M
7 define i32 @xori64i32(i64 %a) {
8 ; CHECK7A-LABEL: xori64i32:
10 ; CHECK7A-NEXT: mvn r0, #-2147483648
11 ; CHECK7A-NEXT: eor r0, r0, r1, asr #31
14 ; CHECK6M-LABEL: xori64i32:
16 ; CHECK6M-NEXT: asrs r1, r1, #31
17 ; CHECK6M-NEXT: ldr r0, .LCPI0_0
18 ; CHECK6M-NEXT: eors r0, r1
20 ; CHECK6M-NEXT: .p2align 2
21 ; CHECK6M-NEXT: @ %bb.1:
22 ; CHECK6M-NEXT: .LCPI0_0:
23 ; CHECK6M-NEXT: .long 2147483647 @ 0x7fffffff
25 ; CHECK7M-LABEL: xori64i32:
27 ; CHECK7M-NEXT: mvn r0, #-2147483648
28 ; CHECK7M-NEXT: eor.w r0, r0, r1, asr #31
31 ; CHECK81M-LABEL: xori64i32:
33 ; CHECK81M-NEXT: mvn r0, #-2147483648
34 ; CHECK81M-NEXT: eor.w r0, r0, r1, asr #31
35 ; CHECK81M-NEXT: bx lr
36 %shr4 = ashr i64 %a, 63
37 %conv5 = trunc i64 %shr4 to i32
38 %xor = xor i32 %conv5, 2147483647
42 define i64 @selecti64i64(i64 %a) {
43 ; CHECK7A-LABEL: selecti64i64:
45 ; CHECK7A-NEXT: mvn r0, #-2147483648
46 ; CHECK7A-NEXT: eor r0, r0, r1, asr #31
47 ; CHECK7A-NEXT: asr r1, r1, #31
50 ; CHECK6M-LABEL: selecti64i64:
52 ; CHECK6M-NEXT: asrs r1, r1, #31
53 ; CHECK6M-NEXT: ldr r0, .LCPI1_0
54 ; CHECK6M-NEXT: eors r0, r1
56 ; CHECK6M-NEXT: .p2align 2
57 ; CHECK6M-NEXT: @ %bb.1:
58 ; CHECK6M-NEXT: .LCPI1_0:
59 ; CHECK6M-NEXT: .long 2147483647 @ 0x7fffffff
61 ; CHECK7M-LABEL: selecti64i64:
63 ; CHECK7M-NEXT: mvn r0, #-2147483648
64 ; CHECK7M-NEXT: eor.w r0, r0, r1, asr #31
65 ; CHECK7M-NEXT: asrs r1, r1, #31
68 ; CHECK81M-LABEL: selecti64i64:
70 ; CHECK81M-NEXT: mvn r0, #-2147483648
71 ; CHECK81M-NEXT: eor.w r0, r0, r1, asr #31
72 ; CHECK81M-NEXT: asrs r1, r1, #31
73 ; CHECK81M-NEXT: bx lr
74 %c = icmp sgt i64 %a, -1
75 %s = select i1 %c, i64 2147483647, i64 -2147483648
79 define i32 @selecti64i32(i64 %a) {
80 ; CHECK7A-LABEL: selecti64i32:
82 ; CHECK7A-NEXT: mvn r0, #-2147483648
83 ; CHECK7A-NEXT: eor r0, r0, r1, asr #31
86 ; CHECK6M-LABEL: selecti64i32:
88 ; CHECK6M-NEXT: ldr r0, .LCPI2_0
89 ; CHECK6M-NEXT: cmp r1, #0
90 ; CHECK6M-NEXT: bge .LBB2_2
91 ; CHECK6M-NEXT: @ %bb.1:
92 ; CHECK6M-NEXT: adds r0, r0, #1
93 ; CHECK6M-NEXT: .LBB2_2:
95 ; CHECK6M-NEXT: .p2align 2
96 ; CHECK6M-NEXT: @ %bb.3:
97 ; CHECK6M-NEXT: .LCPI2_0:
98 ; CHECK6M-NEXT: .long 2147483647 @ 0x7fffffff
100 ; CHECK7M-LABEL: selecti64i32:
102 ; CHECK7M-NEXT: mvn r0, #-2147483648
103 ; CHECK7M-NEXT: eor.w r0, r0, r1, asr #31
104 ; CHECK7M-NEXT: bx lr
106 ; CHECK81M-LABEL: selecti64i32:
108 ; CHECK81M-NEXT: mvn r0, #-2147483648
109 ; CHECK81M-NEXT: eor.w r0, r0, r1, asr #31
110 ; CHECK81M-NEXT: bx lr
111 %c = icmp sgt i64 %a, -1
112 %s = select i1 %c, i32 2147483647, i32 -2147483648
116 define i64 @selecti32i64(i32 %a) {
117 ; CHECK7A-LABEL: selecti32i64:
119 ; CHECK7A-NEXT: mvn r1, #-2147483648
120 ; CHECK7A-NEXT: eor r2, r1, r0, asr #31
121 ; CHECK7A-NEXT: asr r1, r0, #31
122 ; CHECK7A-NEXT: mov r0, r2
123 ; CHECK7A-NEXT: bx lr
125 ; CHECK6M-LABEL: selecti32i64:
127 ; CHECK6M-NEXT: asrs r1, r0, #31
128 ; CHECK6M-NEXT: ldr r0, .LCPI3_0
129 ; CHECK6M-NEXT: eors r0, r1
130 ; CHECK6M-NEXT: bx lr
131 ; CHECK6M-NEXT: .p2align 2
132 ; CHECK6M-NEXT: @ %bb.1:
133 ; CHECK6M-NEXT: .LCPI3_0:
134 ; CHECK6M-NEXT: .long 2147483647 @ 0x7fffffff
136 ; CHECK7M-LABEL: selecti32i64:
138 ; CHECK7M-NEXT: mvn r1, #-2147483648
139 ; CHECK7M-NEXT: eor.w r2, r1, r0, asr #31
140 ; CHECK7M-NEXT: asrs r1, r0, #31
141 ; CHECK7M-NEXT: mov r0, r2
142 ; CHECK7M-NEXT: bx lr
144 ; CHECK81M-LABEL: selecti32i64:
146 ; CHECK81M-NEXT: mvn r1, #-2147483648
147 ; CHECK81M-NEXT: eor.w r2, r1, r0, asr #31
148 ; CHECK81M-NEXT: asrs r1, r0, #31
149 ; CHECK81M-NEXT: mov r0, r2
150 ; CHECK81M-NEXT: bx lr
151 %c = icmp sgt i32 %a, -1
152 %s = select i1 %c, i64 2147483647, i64 -2147483648
158 define i8 @xori32i8(i32 %a) {
159 ; CHECK7A-LABEL: xori32i8:
161 ; CHECK7A-NEXT: mov r1, #84
162 ; CHECK7A-NEXT: eor r0, r1, r0, asr #31
163 ; CHECK7A-NEXT: bx lr
165 ; CHECK6M-LABEL: xori32i8:
167 ; CHECK6M-NEXT: asrs r1, r0, #31
168 ; CHECK6M-NEXT: movs r0, #84
169 ; CHECK6M-NEXT: eors r0, r1
170 ; CHECK6M-NEXT: bx lr
172 ; CHECK7M-LABEL: xori32i8:
174 ; CHECK7M-NEXT: movs r1, #84
175 ; CHECK7M-NEXT: eor.w r0, r1, r0, asr #31
176 ; CHECK7M-NEXT: bx lr
178 ; CHECK81M-LABEL: xori32i8:
180 ; CHECK81M-NEXT: movs r1, #84
181 ; CHECK81M-NEXT: eor.w r0, r1, r0, asr #31
182 ; CHECK81M-NEXT: bx lr
183 %shr4 = ashr i32 %a, 31
184 %conv5 = trunc i32 %shr4 to i8
185 %xor = xor i8 %conv5, 84
189 define i32 @selecti32i32(i32 %a) {
190 ; CHECK7A-LABEL: selecti32i32:
192 ; CHECK7A-NEXT: mov r1, #84
193 ; CHECK7A-NEXT: eor r0, r1, r0, asr #31
194 ; CHECK7A-NEXT: bx lr
196 ; CHECK6M-LABEL: selecti32i32:
198 ; CHECK6M-NEXT: asrs r1, r0, #31
199 ; CHECK6M-NEXT: movs r0, #84
200 ; CHECK6M-NEXT: eors r0, r1
201 ; CHECK6M-NEXT: bx lr
203 ; CHECK7M-LABEL: selecti32i32:
205 ; CHECK7M-NEXT: movs r1, #84
206 ; CHECK7M-NEXT: eor.w r0, r1, r0, asr #31
207 ; CHECK7M-NEXT: bx lr
209 ; CHECK81M-LABEL: selecti32i32:
211 ; CHECK81M-NEXT: movs r1, #84
212 ; CHECK81M-NEXT: eor.w r0, r1, r0, asr #31
213 ; CHECK81M-NEXT: bx lr
214 %c = icmp sgt i32 %a, -1
215 %s = select i1 %c, i32 84, i32 -85
219 define i8 @selecti32i8(i32 %a) {
220 ; CHECK7A-LABEL: selecti32i8:
222 ; CHECK7A-NEXT: mov r1, #84
223 ; CHECK7A-NEXT: eor r0, r1, r0, asr #31
224 ; CHECK7A-NEXT: bx lr
226 ; CHECK6M-LABEL: selecti32i8:
228 ; CHECK6M-NEXT: asrs r1, r0, #31
229 ; CHECK6M-NEXT: movs r0, #84
230 ; CHECK6M-NEXT: eors r0, r1
231 ; CHECK6M-NEXT: bx lr
233 ; CHECK7M-LABEL: selecti32i8:
235 ; CHECK7M-NEXT: movs r1, #84
236 ; CHECK7M-NEXT: eor.w r0, r1, r0, asr #31
237 ; CHECK7M-NEXT: bx lr
239 ; CHECK81M-LABEL: selecti32i8:
241 ; CHECK81M-NEXT: movs r1, #84
242 ; CHECK81M-NEXT: eor.w r0, r1, r0, asr #31
243 ; CHECK81M-NEXT: bx lr
244 %c = icmp sgt i32 %a, -1
245 %s = select i1 %c, i8 84, i8 -85
249 define i32 @selecti8i32(i8 %a) {
250 ; CHECK7A-LABEL: selecti8i32:
252 ; CHECK7A-NEXT: sxtb r0, r0
253 ; CHECK7A-NEXT: mov r1, #84
254 ; CHECK7A-NEXT: eor r0, r1, r0, asr #7
255 ; CHECK7A-NEXT: bx lr
257 ; CHECK6M-LABEL: selecti8i32:
259 ; CHECK6M-NEXT: sxtb r0, r0
260 ; CHECK6M-NEXT: asrs r1, r0, #7
261 ; CHECK6M-NEXT: movs r0, #84
262 ; CHECK6M-NEXT: eors r0, r1
263 ; CHECK6M-NEXT: bx lr
265 ; CHECK7M-LABEL: selecti8i32:
267 ; CHECK7M-NEXT: sxtb r0, r0
268 ; CHECK7M-NEXT: movs r1, #84
269 ; CHECK7M-NEXT: eor.w r0, r1, r0, asr #7
270 ; CHECK7M-NEXT: bx lr
272 ; CHECK81M-LABEL: selecti8i32:
274 ; CHECK81M-NEXT: sxtb r0, r0
275 ; CHECK81M-NEXT: movs r1, #84
276 ; CHECK81M-NEXT: eor.w r0, r1, r0, asr #7
277 ; CHECK81M-NEXT: bx lr
278 %c = icmp sgt i8 %a, -1
279 %s = select i1 %c, i32 84, i32 -85
283 define i32 @icmpasreq(i32 %input, i32 %a, i32 %b) {
284 ; CHECK7A-LABEL: icmpasreq:
286 ; CHECK7A-NEXT: cmp r0, #0
287 ; CHECK7A-NEXT: movpl r1, r2
288 ; CHECK7A-NEXT: mov r0, r1
289 ; CHECK7A-NEXT: bx lr
291 ; CHECK6M-LABEL: icmpasreq:
293 ; CHECK6M-NEXT: cmp r0, #0
294 ; CHECK6M-NEXT: bmi .LBB8_2
295 ; CHECK6M-NEXT: @ %bb.1:
296 ; CHECK6M-NEXT: mov r1, r2
297 ; CHECK6M-NEXT: .LBB8_2:
298 ; CHECK6M-NEXT: mov r0, r1
299 ; CHECK6M-NEXT: bx lr
301 ; CHECK7M-LABEL: icmpasreq:
303 ; CHECK7M-NEXT: cmp r0, #0
304 ; CHECK7M-NEXT: it pl
305 ; CHECK7M-NEXT: movpl r1, r2
306 ; CHECK7M-NEXT: mov r0, r1
307 ; CHECK7M-NEXT: bx lr
309 ; CHECK81M-LABEL: icmpasreq:
311 ; CHECK81M-NEXT: cmp r0, #0
312 ; CHECK81M-NEXT: csel r0, r1, r2, mi
313 ; CHECK81M-NEXT: bx lr
314 %sh = ashr i32 %input, 31
315 %c = icmp eq i32 %sh, -1
316 %s = select i1 %c, i32 %a, i32 %b
320 define i32 @icmpasrne(i32 %input, i32 %a, i32 %b) {
321 ; CHECK7A-LABEL: icmpasrne:
323 ; CHECK7A-NEXT: cmn r0, #1
324 ; CHECK7A-NEXT: movle r1, r2
325 ; CHECK7A-NEXT: mov r0, r1
326 ; CHECK7A-NEXT: bx lr
328 ; CHECK6M-LABEL: icmpasrne:
330 ; CHECK6M-NEXT: cmp r0, #0
331 ; CHECK6M-NEXT: bge .LBB9_2
332 ; CHECK6M-NEXT: @ %bb.1:
333 ; CHECK6M-NEXT: mov r1, r2
334 ; CHECK6M-NEXT: .LBB9_2:
335 ; CHECK6M-NEXT: mov r0, r1
336 ; CHECK6M-NEXT: bx lr
338 ; CHECK7M-LABEL: icmpasrne:
340 ; CHECK7M-NEXT: cmp.w r0, #-1
341 ; CHECK7M-NEXT: it le
342 ; CHECK7M-NEXT: movle r1, r2
343 ; CHECK7M-NEXT: mov r0, r1
344 ; CHECK7M-NEXT: bx lr
346 ; CHECK81M-LABEL: icmpasrne:
348 ; CHECK81M-NEXT: cmp.w r0, #-1
349 ; CHECK81M-NEXT: csel r0, r1, r2, gt
350 ; CHECK81M-NEXT: bx lr
351 %sh = ashr i32 %input, 31
352 %c = icmp ne i32 %sh, -1
353 %s = select i1 %c, i32 %a, i32 %b
357 define i32 @oneusecmp(i32 %a, i32 %b, i32 %d) {
358 ; CHECK7A-LABEL: oneusecmp:
360 ; CHECK7A-NEXT: cmp r0, #0
361 ; CHECK7A-NEXT: movmi r1, r2
362 ; CHECK7A-NEXT: mov r2, #127
363 ; CHECK7A-NEXT: eor r0, r2, r0, asr #31
364 ; CHECK7A-NEXT: add r0, r0, r1
365 ; CHECK7A-NEXT: bx lr
367 ; CHECK6M-LABEL: oneusecmp:
369 ; CHECK6M-NEXT: cmp r0, #0
370 ; CHECK6M-NEXT: bmi .LBB10_2
371 ; CHECK6M-NEXT: @ %bb.1:
372 ; CHECK6M-NEXT: mov r2, r1
373 ; CHECK6M-NEXT: .LBB10_2:
374 ; CHECK6M-NEXT: asrs r0, r0, #31
375 ; CHECK6M-NEXT: movs r1, #127
376 ; CHECK6M-NEXT: eors r1, r0
377 ; CHECK6M-NEXT: adds r0, r1, r2
378 ; CHECK6M-NEXT: bx lr
380 ; CHECK7M-LABEL: oneusecmp:
382 ; CHECK7M-NEXT: cmp r0, #0
383 ; CHECK7M-NEXT: it mi
384 ; CHECK7M-NEXT: movmi r1, r2
385 ; CHECK7M-NEXT: movs r2, #127
386 ; CHECK7M-NEXT: eor.w r0, r2, r0, asr #31
387 ; CHECK7M-NEXT: add r0, r1
388 ; CHECK7M-NEXT: bx lr
390 ; CHECK81M-LABEL: oneusecmp:
392 ; CHECK81M-NEXT: cmp r0, #0
393 ; CHECK81M-NEXT: csel r1, r2, r1, mi
394 ; CHECK81M-NEXT: movs r2, #127
395 ; CHECK81M-NEXT: eor.w r0, r2, r0, asr #31
396 ; CHECK81M-NEXT: add r0, r1
397 ; CHECK81M-NEXT: bx lr
398 %c = icmp sle i32 %a, -1
399 %s = select i1 %c, i32 -128, i32 127
400 %s2 = select i1 %c, i32 %d, i32 %b