1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=armv7-linux-gnueabihf %s -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-ARM
3 ; RUN: llc -mtriple=armv7eb-linux-gnueabihf %s -o - | FileCheck %s --check-prefixes=CHECK-BE
4 ; RUN: llc -mtriple=thumbv7-linux-gnueabihf %s -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-THUMB
5 ; RUN: llc -mtriple=thumbv7m %s -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-THUMB
6 ; RUN: llc -mtriple=thumbv7m -mattr=+strict-align %s -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-ALIGN
7 ; RUN: llc -mtriple=thumbv6m %s -o - | FileCheck %s --check-prefix=CHECK-V6M
9 @array = weak global [4 x i32] zeroinitializer
11 define i32 @test_lshr_and1(i32 %x) {
12 ; CHECK-COMMON-LABEL: test_lshr_and1:
13 ; CHECK-COMMON: @ %bb.0: @ %entry
14 ; CHECK-COMMON-NEXT: movw r1, :lower16:array
15 ; CHECK-COMMON-NEXT: and r0, r0, #12
16 ; CHECK-COMMON-NEXT: movt r1, :upper16:array
17 ; CHECK-COMMON-NEXT: ldr r0, [r1, r0]
18 ; CHECK-COMMON-NEXT: bx lr
20 ; CHECK-BE-LABEL: test_lshr_and1:
21 ; CHECK-BE: @ %bb.0: @ %entry
22 ; CHECK-BE-NEXT: movw r1, :lower16:array
23 ; CHECK-BE-NEXT: and r0, r0, #12
24 ; CHECK-BE-NEXT: movt r1, :upper16:array
25 ; CHECK-BE-NEXT: ldr r0, [r1, r0]
26 ; CHECK-BE-NEXT: bx lr
28 ; CHECK-V6M-LABEL: test_lshr_and1:
29 ; CHECK-V6M: @ %bb.0: @ %entry
30 ; CHECK-V6M-NEXT: movs r1, #12
31 ; CHECK-V6M-NEXT: ands r1, r0
32 ; CHECK-V6M-NEXT: ldr r0, .LCPI0_0
33 ; CHECK-V6M-NEXT: ldr r0, [r0, r1]
34 ; CHECK-V6M-NEXT: bx lr
35 ; CHECK-V6M-NEXT: .p2align 2
36 ; CHECK-V6M-NEXT: @ %bb.1:
37 ; CHECK-V6M-NEXT: .LCPI0_0:
38 ; CHECK-V6M-NEXT: .long array
40 %tmp2 = lshr i32 %x, 2
41 %tmp3 = and i32 %tmp2, 3
42 %tmp4 = getelementptr [4 x i32], ptr @array, i32 0, i32 %tmp3
43 %tmp5 = load i32, ptr %tmp4, align 4
46 define i32 @test_lshr_and2(i32 %x) {
47 ; CHECK-ARM-LABEL: test_lshr_and2:
48 ; CHECK-ARM: @ %bb.0: @ %entry
49 ; CHECK-ARM-NEXT: ubfx r0, r0, #1, #15
50 ; CHECK-ARM-NEXT: add r0, r0, r0
51 ; CHECK-ARM-NEXT: bx lr
53 ; CHECK-BE-LABEL: test_lshr_and2:
54 ; CHECK-BE: @ %bb.0: @ %entry
55 ; CHECK-BE-NEXT: ubfx r0, r0, #1, #15
56 ; CHECK-BE-NEXT: add r0, r0, r0
57 ; CHECK-BE-NEXT: bx lr
59 ; CHECK-THUMB-LABEL: test_lshr_and2:
60 ; CHECK-THUMB: @ %bb.0: @ %entry
61 ; CHECK-THUMB-NEXT: ubfx r0, r0, #1, #15
62 ; CHECK-THUMB-NEXT: add r0, r0
63 ; CHECK-THUMB-NEXT: bx lr
65 ; CHECK-ALIGN-LABEL: test_lshr_and2:
66 ; CHECK-ALIGN: @ %bb.0: @ %entry
67 ; CHECK-ALIGN-NEXT: ubfx r0, r0, #1, #15
68 ; CHECK-ALIGN-NEXT: add r0, r0
69 ; CHECK-ALIGN-NEXT: bx lr
71 ; CHECK-V6M-LABEL: test_lshr_and2:
72 ; CHECK-V6M: @ %bb.0: @ %entry
73 ; CHECK-V6M-NEXT: lsls r0, r0, #16
74 ; CHECK-V6M-NEXT: lsrs r0, r0, #17
75 ; CHECK-V6M-NEXT: adds r0, r0, r0
76 ; CHECK-V6M-NEXT: bx lr
78 %a = and i32 %x, 65534
80 %c = and i32 %x, 65535
86 define arm_aapcscc i32 @test_lshr_load1(ptr %a) {
87 ; CHECK-COMMON-LABEL: test_lshr_load1:
88 ; CHECK-COMMON: @ %bb.0: @ %entry
89 ; CHECK-COMMON-NEXT: ldrb r0, [r0, #1]
90 ; CHECK-COMMON-NEXT: bx lr
92 ; CHECK-BE-LABEL: test_lshr_load1:
93 ; CHECK-BE: @ %bb.0: @ %entry
94 ; CHECK-BE-NEXT: ldrb r0, [r0]
95 ; CHECK-BE-NEXT: bx lr
97 ; CHECK-V6M-LABEL: test_lshr_load1:
98 ; CHECK-V6M: @ %bb.0: @ %entry
99 ; CHECK-V6M-NEXT: ldrb r0, [r0, #1]
100 ; CHECK-V6M-NEXT: bx lr
102 %0 = load i16, ptr %a, align 2
103 %conv1 = zext i16 %0 to i32
104 %1 = lshr i32 %conv1, 8
108 define arm_aapcscc i32 @test_lshr_load1_sext(ptr %a) {
109 ; CHECK-ARM-LABEL: test_lshr_load1_sext:
110 ; CHECK-ARM: @ %bb.0: @ %entry
111 ; CHECK-ARM-NEXT: ldrsh r0, [r0]
112 ; CHECK-ARM-NEXT: lsr r0, r0, #8
113 ; CHECK-ARM-NEXT: bx lr
115 ; CHECK-BE-LABEL: test_lshr_load1_sext:
116 ; CHECK-BE: @ %bb.0: @ %entry
117 ; CHECK-BE-NEXT: ldrsh r0, [r0]
118 ; CHECK-BE-NEXT: lsr r0, r0, #8
119 ; CHECK-BE-NEXT: bx lr
121 ; CHECK-THUMB-LABEL: test_lshr_load1_sext:
122 ; CHECK-THUMB: @ %bb.0: @ %entry
123 ; CHECK-THUMB-NEXT: ldrsh.w r0, [r0]
124 ; CHECK-THUMB-NEXT: lsrs r0, r0, #8
125 ; CHECK-THUMB-NEXT: bx lr
127 ; CHECK-ALIGN-LABEL: test_lshr_load1_sext:
128 ; CHECK-ALIGN: @ %bb.0: @ %entry
129 ; CHECK-ALIGN-NEXT: ldrsh.w r0, [r0]
130 ; CHECK-ALIGN-NEXT: lsrs r0, r0, #8
131 ; CHECK-ALIGN-NEXT: bx lr
133 ; CHECK-V6M-LABEL: test_lshr_load1_sext:
134 ; CHECK-V6M: @ %bb.0: @ %entry
135 ; CHECK-V6M-NEXT: movs r1, #0
136 ; CHECK-V6M-NEXT: ldrsh r0, [r0, r1]
137 ; CHECK-V6M-NEXT: lsrs r0, r0, #8
138 ; CHECK-V6M-NEXT: bx lr
140 %0 = load i16, ptr %a, align 2
141 %conv1 = sext i16 %0 to i32
142 %1 = lshr i32 %conv1, 8
146 define arm_aapcscc i32 @test_lshr_load1_fail(ptr %a) {
147 ; CHECK-ARM-LABEL: test_lshr_load1_fail:
148 ; CHECK-ARM: @ %bb.0: @ %entry
149 ; CHECK-ARM-NEXT: ldrh r0, [r0]
150 ; CHECK-ARM-NEXT: lsr r0, r0, #9
151 ; CHECK-ARM-NEXT: bx lr
153 ; CHECK-BE-LABEL: test_lshr_load1_fail:
154 ; CHECK-BE: @ %bb.0: @ %entry
155 ; CHECK-BE-NEXT: ldrh r0, [r0]
156 ; CHECK-BE-NEXT: lsr r0, r0, #9
157 ; CHECK-BE-NEXT: bx lr
159 ; CHECK-THUMB-LABEL: test_lshr_load1_fail:
160 ; CHECK-THUMB: @ %bb.0: @ %entry
161 ; CHECK-THUMB-NEXT: ldrh r0, [r0]
162 ; CHECK-THUMB-NEXT: lsrs r0, r0, #9
163 ; CHECK-THUMB-NEXT: bx lr
165 ; CHECK-ALIGN-LABEL: test_lshr_load1_fail:
166 ; CHECK-ALIGN: @ %bb.0: @ %entry
167 ; CHECK-ALIGN-NEXT: ldrh r0, [r0]
168 ; CHECK-ALIGN-NEXT: lsrs r0, r0, #9
169 ; CHECK-ALIGN-NEXT: bx lr
171 ; CHECK-V6M-LABEL: test_lshr_load1_fail:
172 ; CHECK-V6M: @ %bb.0: @ %entry
173 ; CHECK-V6M-NEXT: ldrh r0, [r0]
174 ; CHECK-V6M-NEXT: lsrs r0, r0, #9
175 ; CHECK-V6M-NEXT: bx lr
177 %0 = load i16, ptr %a, align 2
178 %conv1 = zext i16 %0 to i32
179 %1 = lshr i32 %conv1, 9
183 define arm_aapcscc i32 @test_lshr_load32(ptr %a) {
184 ; CHECK-ARM-LABEL: test_lshr_load32:
185 ; CHECK-ARM: @ %bb.0: @ %entry
186 ; CHECK-ARM-NEXT: ldr r0, [r0]
187 ; CHECK-ARM-NEXT: lsr r0, r0, #8
188 ; CHECK-ARM-NEXT: bx lr
190 ; CHECK-BE-LABEL: test_lshr_load32:
191 ; CHECK-BE: @ %bb.0: @ %entry
192 ; CHECK-BE-NEXT: ldr r0, [r0]
193 ; CHECK-BE-NEXT: lsr r0, r0, #8
194 ; CHECK-BE-NEXT: bx lr
196 ; CHECK-THUMB-LABEL: test_lshr_load32:
197 ; CHECK-THUMB: @ %bb.0: @ %entry
198 ; CHECK-THUMB-NEXT: ldr r0, [r0]
199 ; CHECK-THUMB-NEXT: lsrs r0, r0, #8
200 ; CHECK-THUMB-NEXT: bx lr
202 ; CHECK-ALIGN-LABEL: test_lshr_load32:
203 ; CHECK-ALIGN: @ %bb.0: @ %entry
204 ; CHECK-ALIGN-NEXT: ldr r0, [r0]
205 ; CHECK-ALIGN-NEXT: lsrs r0, r0, #8
206 ; CHECK-ALIGN-NEXT: bx lr
208 ; CHECK-V6M-LABEL: test_lshr_load32:
209 ; CHECK-V6M: @ %bb.0: @ %entry
210 ; CHECK-V6M-NEXT: ldr r0, [r0]
211 ; CHECK-V6M-NEXT: lsrs r0, r0, #8
212 ; CHECK-V6M-NEXT: bx lr
214 %0 = load i32, ptr %a, align 4
219 define arm_aapcscc i32 @test_lshr_load32_2(ptr %a) {
220 ; CHECK-COMMON-LABEL: test_lshr_load32_2:
221 ; CHECK-COMMON: @ %bb.0: @ %entry
222 ; CHECK-COMMON-NEXT: ldrh r0, [r0, #2]
223 ; CHECK-COMMON-NEXT: bx lr
225 ; CHECK-BE-LABEL: test_lshr_load32_2:
226 ; CHECK-BE: @ %bb.0: @ %entry
227 ; CHECK-BE-NEXT: ldrh r0, [r0]
228 ; CHECK-BE-NEXT: bx lr
230 ; CHECK-V6M-LABEL: test_lshr_load32_2:
231 ; CHECK-V6M: @ %bb.0: @ %entry
232 ; CHECK-V6M-NEXT: ldrh r0, [r0, #2]
233 ; CHECK-V6M-NEXT: bx lr
235 %0 = load i32, ptr %a, align 4
240 define arm_aapcscc i32 @test_lshr_load32_1(ptr %a) {
241 ; CHECK-COMMON-LABEL: test_lshr_load32_1:
242 ; CHECK-COMMON: @ %bb.0: @ %entry
243 ; CHECK-COMMON-NEXT: ldrb r0, [r0, #3]
244 ; CHECK-COMMON-NEXT: bx lr
246 ; CHECK-BE-LABEL: test_lshr_load32_1:
247 ; CHECK-BE: @ %bb.0: @ %entry
248 ; CHECK-BE-NEXT: ldrb r0, [r0]
249 ; CHECK-BE-NEXT: bx lr
251 ; CHECK-V6M-LABEL: test_lshr_load32_1:
252 ; CHECK-V6M: @ %bb.0: @ %entry
253 ; CHECK-V6M-NEXT: ldrb r0, [r0, #3]
254 ; CHECK-V6M-NEXT: bx lr
256 %0 = load i32, ptr %a, align 4
261 define arm_aapcscc i32 @test_lshr_load32_fail(ptr %a) {
262 ; CHECK-ARM-LABEL: test_lshr_load32_fail:
263 ; CHECK-ARM: @ %bb.0: @ %entry
264 ; CHECK-ARM-NEXT: ldr r0, [r0]
265 ; CHECK-ARM-NEXT: lsr r0, r0, #15
266 ; CHECK-ARM-NEXT: bx lr
268 ; CHECK-BE-LABEL: test_lshr_load32_fail:
269 ; CHECK-BE: @ %bb.0: @ %entry
270 ; CHECK-BE-NEXT: ldr r0, [r0]
271 ; CHECK-BE-NEXT: lsr r0, r0, #15
272 ; CHECK-BE-NEXT: bx lr
274 ; CHECK-THUMB-LABEL: test_lshr_load32_fail:
275 ; CHECK-THUMB: @ %bb.0: @ %entry
276 ; CHECK-THUMB-NEXT: ldr r0, [r0]
277 ; CHECK-THUMB-NEXT: lsrs r0, r0, #15
278 ; CHECK-THUMB-NEXT: bx lr
280 ; CHECK-ALIGN-LABEL: test_lshr_load32_fail:
281 ; CHECK-ALIGN: @ %bb.0: @ %entry
282 ; CHECK-ALIGN-NEXT: ldr r0, [r0]
283 ; CHECK-ALIGN-NEXT: lsrs r0, r0, #15
284 ; CHECK-ALIGN-NEXT: bx lr
286 ; CHECK-V6M-LABEL: test_lshr_load32_fail:
287 ; CHECK-V6M: @ %bb.0: @ %entry
288 ; CHECK-V6M-NEXT: ldr r0, [r0]
289 ; CHECK-V6M-NEXT: lsrs r0, r0, #15
290 ; CHECK-V6M-NEXT: bx lr
292 %0 = load i32, ptr %a, align 4
297 define arm_aapcscc i32 @test_lshr_load64_4_unaligned(ptr %a) {
298 ; CHECK-ARM-LABEL: test_lshr_load64_4_unaligned:
299 ; CHECK-ARM: @ %bb.0: @ %entry
300 ; CHECK-ARM-NEXT: ldr r0, [r0, #2]
301 ; CHECK-ARM-NEXT: bx lr
303 ; CHECK-BE-LABEL: test_lshr_load64_4_unaligned:
304 ; CHECK-BE: @ %bb.0: @ %entry
305 ; CHECK-BE-NEXT: ldr r0, [r0, #2]
306 ; CHECK-BE-NEXT: bx lr
308 ; CHECK-THUMB-LABEL: test_lshr_load64_4_unaligned:
309 ; CHECK-THUMB: @ %bb.0: @ %entry
310 ; CHECK-THUMB-NEXT: ldr.w r0, [r0, #2]
311 ; CHECK-THUMB-NEXT: bx lr
313 ; CHECK-ALIGN-LABEL: test_lshr_load64_4_unaligned:
314 ; CHECK-ALIGN: @ %bb.0: @ %entry
315 ; CHECK-ALIGN-NEXT: ldr r1, [r0, #4]
316 ; CHECK-ALIGN-NEXT: ldrh r0, [r0, #2]
317 ; CHECK-ALIGN-NEXT: orr.w r0, r0, r1, lsl #16
318 ; CHECK-ALIGN-NEXT: bx lr
320 ; CHECK-V6M-LABEL: test_lshr_load64_4_unaligned:
321 ; CHECK-V6M: @ %bb.0: @ %entry
322 ; CHECK-V6M-NEXT: ldrh r1, [r0, #2]
323 ; CHECK-V6M-NEXT: ldr r0, [r0, #4]
324 ; CHECK-V6M-NEXT: lsls r0, r0, #16
325 ; CHECK-V6M-NEXT: adds r0, r1, r0
326 ; CHECK-V6M-NEXT: bx lr
328 %0 = load i64, ptr %a, align 8
330 %conv = trunc i64 %1 to i32
334 define arm_aapcscc i32 @test_lshr_load64_1_lsb(ptr %a) {
335 ; CHECK-ARM-LABEL: test_lshr_load64_1_lsb:
336 ; CHECK-ARM: @ %bb.0: @ %entry
337 ; CHECK-ARM-NEXT: ldr r0, [r0, #3]
338 ; CHECK-ARM-NEXT: bx lr
340 ; CHECK-BE-LABEL: test_lshr_load64_1_lsb:
341 ; CHECK-BE: @ %bb.0: @ %entry
342 ; CHECK-BE-NEXT: ldr r0, [r0, #1]
343 ; CHECK-BE-NEXT: bx lr
345 ; CHECK-THUMB-LABEL: test_lshr_load64_1_lsb:
346 ; CHECK-THUMB: @ %bb.0: @ %entry
347 ; CHECK-THUMB-NEXT: ldr.w r0, [r0, #3]
348 ; CHECK-THUMB-NEXT: bx lr
350 ; CHECK-ALIGN-LABEL: test_lshr_load64_1_lsb:
351 ; CHECK-ALIGN: @ %bb.0: @ %entry
352 ; CHECK-ALIGN-NEXT: ldr r1, [r0, #4]
353 ; CHECK-ALIGN-NEXT: ldrb r0, [r0, #3]
354 ; CHECK-ALIGN-NEXT: orr.w r0, r0, r1, lsl #8
355 ; CHECK-ALIGN-NEXT: bx lr
357 ; CHECK-V6M-LABEL: test_lshr_load64_1_lsb:
358 ; CHECK-V6M: @ %bb.0: @ %entry
359 ; CHECK-V6M-NEXT: ldrb r1, [r0, #3]
360 ; CHECK-V6M-NEXT: ldr r0, [r0, #4]
361 ; CHECK-V6M-NEXT: lsls r0, r0, #8
362 ; CHECK-V6M-NEXT: adds r0, r1, r0
363 ; CHECK-V6M-NEXT: bx lr
365 %0 = load i64, ptr %a, align 8
367 %conv = trunc i64 %1 to i32
371 define arm_aapcscc i32 @test_lshr_load64_1_msb(ptr %a) {
372 ; CHECK-COMMON-LABEL: test_lshr_load64_1_msb:
373 ; CHECK-COMMON: @ %bb.0: @ %entry
374 ; CHECK-COMMON-NEXT: ldrb r0, [r0, #7]
375 ; CHECK-COMMON-NEXT: bx lr
377 ; CHECK-BE-LABEL: test_lshr_load64_1_msb:
378 ; CHECK-BE: @ %bb.0: @ %entry
379 ; CHECK-BE-NEXT: ldrb r0, [r0]
380 ; CHECK-BE-NEXT: bx lr
382 ; CHECK-V6M-LABEL: test_lshr_load64_1_msb:
383 ; CHECK-V6M: @ %bb.0: @ %entry
384 ; CHECK-V6M-NEXT: ldrb r0, [r0, #7]
385 ; CHECK-V6M-NEXT: bx lr
387 %0 = load i64, ptr %a, align 8
389 %conv = trunc i64 %1 to i32
393 define arm_aapcscc i32 @test_lshr_load64_4(ptr %a) {
394 ; CHECK-COMMON-LABEL: test_lshr_load64_4:
395 ; CHECK-COMMON: @ %bb.0: @ %entry
396 ; CHECK-COMMON-NEXT: ldr r0, [r0, #4]
397 ; CHECK-COMMON-NEXT: bx lr
399 ; CHECK-BE-LABEL: test_lshr_load64_4:
400 ; CHECK-BE: @ %bb.0: @ %entry
401 ; CHECK-BE-NEXT: ldr r0, [r0]
402 ; CHECK-BE-NEXT: bx lr
404 ; CHECK-V6M-LABEL: test_lshr_load64_4:
405 ; CHECK-V6M: @ %bb.0: @ %entry
406 ; CHECK-V6M-NEXT: ldr r0, [r0, #4]
407 ; CHECK-V6M-NEXT: bx lr
409 %0 = load i64, ptr %a, align 8
411 %conv = trunc i64 %1 to i32
415 define arm_aapcscc i32 @test_lshr_load64_2(ptr %a) {
416 ; CHECK-COMMON-LABEL: test_lshr_load64_2:
417 ; CHECK-COMMON: @ %bb.0: @ %entry
418 ; CHECK-COMMON-NEXT: ldrh r0, [r0, #6]
419 ; CHECK-COMMON-NEXT: bx lr
421 ; CHECK-BE-LABEL: test_lshr_load64_2:
422 ; CHECK-BE: @ %bb.0: @ %entry
423 ; CHECK-BE-NEXT: ldrh r0, [r0]
424 ; CHECK-BE-NEXT: bx lr
426 ; CHECK-V6M-LABEL: test_lshr_load64_2:
427 ; CHECK-V6M: @ %bb.0: @ %entry
428 ; CHECK-V6M-NEXT: ldrh r0, [r0, #6]
429 ; CHECK-V6M-NEXT: bx lr
431 %0 = load i64, ptr %a, align 8
433 %conv = trunc i64 %1 to i32
437 define arm_aapcscc i32 @test_lshr_load4_fail(ptr %a) {
438 ; CHECK-ARM-LABEL: test_lshr_load4_fail:
439 ; CHECK-ARM: @ %bb.0: @ %entry
440 ; CHECK-ARM-NEXT: ldr r0, [r0, #1]
441 ; CHECK-ARM-NEXT: bx lr
443 ; CHECK-BE-LABEL: test_lshr_load4_fail:
444 ; CHECK-BE: @ %bb.0: @ %entry
445 ; CHECK-BE-NEXT: ldr r0, [r0, #3]
446 ; CHECK-BE-NEXT: bx lr
448 ; CHECK-THUMB-LABEL: test_lshr_load4_fail:
449 ; CHECK-THUMB: @ %bb.0: @ %entry
450 ; CHECK-THUMB-NEXT: ldr.w r0, [r0, #1]
451 ; CHECK-THUMB-NEXT: bx lr
453 ; CHECK-ALIGN-LABEL: test_lshr_load4_fail:
454 ; CHECK-ALIGN: @ %bb.0: @ %entry
455 ; CHECK-ALIGN-NEXT: ldrd r0, r1, [r0]
456 ; CHECK-ALIGN-NEXT: lsrs r0, r0, #8
457 ; CHECK-ALIGN-NEXT: orr.w r0, r0, r1, lsl #24
458 ; CHECK-ALIGN-NEXT: bx lr
460 ; CHECK-V6M-LABEL: test_lshr_load4_fail:
461 ; CHECK-V6M: @ %bb.0: @ %entry
462 ; CHECK-V6M-NEXT: ldr r1, [r0]
463 ; CHECK-V6M-NEXT: ldr r0, [r0, #4]
464 ; CHECK-V6M-NEXT: lsls r0, r0, #24
465 ; CHECK-V6M-NEXT: lsrs r1, r1, #8
466 ; CHECK-V6M-NEXT: adds r0, r1, r0
467 ; CHECK-V6M-NEXT: bx lr
469 %0 = load i64, ptr %a, align 8
471 %conv = trunc i64 %1 to i32
475 define arm_aapcscc void @test_shift7_mask8(ptr nocapture %p) {
476 ; CHECK-COMMON-LABEL: test_shift7_mask8:
477 ; CHECK-COMMON: @ %bb.0: @ %entry
478 ; CHECK-COMMON-NEXT: ldr r1, [r0]
479 ; CHECK-COMMON-NEXT: ubfx r1, r1, #7, #8
480 ; CHECK-COMMON-NEXT: str r1, [r0]
481 ; CHECK-COMMON-NEXT: bx lr
483 ; CHECK-BE-LABEL: test_shift7_mask8:
484 ; CHECK-BE: @ %bb.0: @ %entry
485 ; CHECK-BE-NEXT: ldr r1, [r0]
486 ; CHECK-BE-NEXT: ubfx r1, r1, #7, #8
487 ; CHECK-BE-NEXT: str r1, [r0]
488 ; CHECK-BE-NEXT: bx lr
490 ; CHECK-V6M-LABEL: test_shift7_mask8:
491 ; CHECK-V6M: @ %bb.0: @ %entry
492 ; CHECK-V6M-NEXT: ldr r1, [r0]
493 ; CHECK-V6M-NEXT: lsrs r1, r1, #7
494 ; CHECK-V6M-NEXT: uxtb r1, r1
495 ; CHECK-V6M-NEXT: str r1, [r0]
496 ; CHECK-V6M-NEXT: bx lr
498 %0 = load i32, ptr %p, align 4
499 %shl = lshr i32 %0, 7
500 %and = and i32 %shl, 255
501 store i32 %and, ptr %p, align 4
505 define arm_aapcscc void @test_shift8_mask8(ptr nocapture %p) {
506 ; CHECK-COMMON-LABEL: test_shift8_mask8:
507 ; CHECK-COMMON: @ %bb.0: @ %entry
508 ; CHECK-COMMON-NEXT: ldrb r1, [r0, #1]
509 ; CHECK-COMMON-NEXT: str r1, [r0]
510 ; CHECK-COMMON-NEXT: bx lr
512 ; CHECK-BE-LABEL: test_shift8_mask8:
513 ; CHECK-BE: @ %bb.0: @ %entry
514 ; CHECK-BE-NEXT: ldrb r1, [r0, #2]
515 ; CHECK-BE-NEXT: str r1, [r0]
516 ; CHECK-BE-NEXT: bx lr
518 ; CHECK-V6M-LABEL: test_shift8_mask8:
519 ; CHECK-V6M: @ %bb.0: @ %entry
520 ; CHECK-V6M-NEXT: ldrb r1, [r0, #1]
521 ; CHECK-V6M-NEXT: str r1, [r0]
522 ; CHECK-V6M-NEXT: bx lr
524 %0 = load i32, ptr %p, align 4
525 %shl = lshr i32 %0, 8
526 %and = and i32 %shl, 255
527 store i32 %and, ptr %p, align 4
531 define arm_aapcscc void @test_shift8_mask7(ptr nocapture %p) {
532 ; CHECK-COMMON-LABEL: test_shift8_mask7:
533 ; CHECK-COMMON: @ %bb.0: @ %entry
534 ; CHECK-COMMON-NEXT: ldr r1, [r0]
535 ; CHECK-COMMON-NEXT: ubfx r1, r1, #8, #7
536 ; CHECK-COMMON-NEXT: str r1, [r0]
537 ; CHECK-COMMON-NEXT: bx lr
539 ; CHECK-BE-LABEL: test_shift8_mask7:
540 ; CHECK-BE: @ %bb.0: @ %entry
541 ; CHECK-BE-NEXT: ldr r1, [r0]
542 ; CHECK-BE-NEXT: ubfx r1, r1, #8, #7
543 ; CHECK-BE-NEXT: str r1, [r0]
544 ; CHECK-BE-NEXT: bx lr
546 ; CHECK-V6M-LABEL: test_shift8_mask7:
547 ; CHECK-V6M: @ %bb.0: @ %entry
548 ; CHECK-V6M-NEXT: ldr r1, [r0]
549 ; CHECK-V6M-NEXT: lsls r1, r1, #17
550 ; CHECK-V6M-NEXT: lsrs r1, r1, #25
551 ; CHECK-V6M-NEXT: str r1, [r0]
552 ; CHECK-V6M-NEXT: bx lr
554 %0 = load i32, ptr %p, align 4
555 %shl = lshr i32 %0, 8
556 %and = and i32 %shl, 127
557 store i32 %and, ptr %p, align 4
561 define arm_aapcscc void @test_shift9_mask8(ptr nocapture %p) {
562 ; CHECK-COMMON-LABEL: test_shift9_mask8:
563 ; CHECK-COMMON: @ %bb.0: @ %entry
564 ; CHECK-COMMON-NEXT: ldr r1, [r0]
565 ; CHECK-COMMON-NEXT: ubfx r1, r1, #9, #8
566 ; CHECK-COMMON-NEXT: str r1, [r0]
567 ; CHECK-COMMON-NEXT: bx lr
569 ; CHECK-BE-LABEL: test_shift9_mask8:
570 ; CHECK-BE: @ %bb.0: @ %entry
571 ; CHECK-BE-NEXT: ldr r1, [r0]
572 ; CHECK-BE-NEXT: ubfx r1, r1, #9, #8
573 ; CHECK-BE-NEXT: str r1, [r0]
574 ; CHECK-BE-NEXT: bx lr
576 ; CHECK-V6M-LABEL: test_shift9_mask8:
577 ; CHECK-V6M: @ %bb.0: @ %entry
578 ; CHECK-V6M-NEXT: ldr r1, [r0]
579 ; CHECK-V6M-NEXT: lsrs r1, r1, #9
580 ; CHECK-V6M-NEXT: uxtb r1, r1
581 ; CHECK-V6M-NEXT: str r1, [r0]
582 ; CHECK-V6M-NEXT: bx lr
584 %0 = load i32, ptr %p, align 4
585 %shl = lshr i32 %0, 9
586 %and = and i32 %shl, 255
587 store i32 %and, ptr %p, align 4
591 define arm_aapcscc void @test_shift8_mask16(ptr nocapture %p) {
592 ; CHECK-ARM-LABEL: test_shift8_mask16:
593 ; CHECK-ARM: @ %bb.0: @ %entry
594 ; CHECK-ARM-NEXT: ldrh r1, [r0, #1]
595 ; CHECK-ARM-NEXT: str r1, [r0]
596 ; CHECK-ARM-NEXT: bx lr
598 ; CHECK-BE-LABEL: test_shift8_mask16:
599 ; CHECK-BE: @ %bb.0: @ %entry
600 ; CHECK-BE-NEXT: ldrh r1, [r0, #1]
601 ; CHECK-BE-NEXT: str r1, [r0]
602 ; CHECK-BE-NEXT: bx lr
604 ; CHECK-THUMB-LABEL: test_shift8_mask16:
605 ; CHECK-THUMB: @ %bb.0: @ %entry
606 ; CHECK-THUMB-NEXT: ldrh.w r1, [r0, #1]
607 ; CHECK-THUMB-NEXT: str r1, [r0]
608 ; CHECK-THUMB-NEXT: bx lr
610 ; CHECK-ALIGN-LABEL: test_shift8_mask16:
611 ; CHECK-ALIGN: @ %bb.0: @ %entry
612 ; CHECK-ALIGN-NEXT: ldr r1, [r0]
613 ; CHECK-ALIGN-NEXT: ubfx r1, r1, #8, #16
614 ; CHECK-ALIGN-NEXT: str r1, [r0]
615 ; CHECK-ALIGN-NEXT: bx lr
617 ; CHECK-V6M-LABEL: test_shift8_mask16:
618 ; CHECK-V6M: @ %bb.0: @ %entry
619 ; CHECK-V6M-NEXT: ldr r1, [r0]
620 ; CHECK-V6M-NEXT: lsrs r1, r1, #8
621 ; CHECK-V6M-NEXT: uxth r1, r1
622 ; CHECK-V6M-NEXT: str r1, [r0]
623 ; CHECK-V6M-NEXT: bx lr
625 %0 = load i32, ptr %p, align 4
626 %shl = lshr i32 %0, 8
627 %and = and i32 %shl, 65535
628 store i32 %and, ptr %p, align 4
632 define arm_aapcscc void @test_shift15_mask16(ptr nocapture %p) {
633 ; CHECK-COMMON-LABEL: test_shift15_mask16:
634 ; CHECK-COMMON: @ %bb.0: @ %entry
635 ; CHECK-COMMON-NEXT: ldr r1, [r0]
636 ; CHECK-COMMON-NEXT: ubfx r1, r1, #15, #16
637 ; CHECK-COMMON-NEXT: str r1, [r0]
638 ; CHECK-COMMON-NEXT: bx lr
640 ; CHECK-BE-LABEL: test_shift15_mask16:
641 ; CHECK-BE: @ %bb.0: @ %entry
642 ; CHECK-BE-NEXT: ldr r1, [r0]
643 ; CHECK-BE-NEXT: ubfx r1, r1, #15, #16
644 ; CHECK-BE-NEXT: str r1, [r0]
645 ; CHECK-BE-NEXT: bx lr
647 ; CHECK-V6M-LABEL: test_shift15_mask16:
648 ; CHECK-V6M: @ %bb.0: @ %entry
649 ; CHECK-V6M-NEXT: ldr r1, [r0]
650 ; CHECK-V6M-NEXT: lsrs r1, r1, #15
651 ; CHECK-V6M-NEXT: uxth r1, r1
652 ; CHECK-V6M-NEXT: str r1, [r0]
653 ; CHECK-V6M-NEXT: bx lr
655 %0 = load i32, ptr %p, align 4
656 %shl = lshr i32 %0, 15
657 %and = and i32 %shl, 65535
658 store i32 %and, ptr %p, align 4
662 define arm_aapcscc void @test_shift16_mask15(ptr nocapture %p) {
663 ; CHECK-COMMON-LABEL: test_shift16_mask15:
664 ; CHECK-COMMON: @ %bb.0: @ %entry
665 ; CHECK-COMMON-NEXT: ldrh r1, [r0, #2]
666 ; CHECK-COMMON-NEXT: bfc r1, #15, #17
667 ; CHECK-COMMON-NEXT: str r1, [r0]
668 ; CHECK-COMMON-NEXT: bx lr
670 ; CHECK-BE-LABEL: test_shift16_mask15:
671 ; CHECK-BE: @ %bb.0: @ %entry
672 ; CHECK-BE-NEXT: ldrh r1, [r0]
673 ; CHECK-BE-NEXT: bfc r1, #15, #17
674 ; CHECK-BE-NEXT: str r1, [r0]
675 ; CHECK-BE-NEXT: bx lr
677 ; CHECK-V6M-LABEL: test_shift16_mask15:
678 ; CHECK-V6M: @ %bb.0: @ %entry
679 ; CHECK-V6M-NEXT: ldrh r1, [r0, #2]
680 ; CHECK-V6M-NEXT: ldr r2, .LCPI21_0
681 ; CHECK-V6M-NEXT: ands r2, r1
682 ; CHECK-V6M-NEXT: str r2, [r0]
683 ; CHECK-V6M-NEXT: bx lr
684 ; CHECK-V6M-NEXT: .p2align 2
685 ; CHECK-V6M-NEXT: @ %bb.1:
686 ; CHECK-V6M-NEXT: .LCPI21_0:
687 ; CHECK-V6M-NEXT: .long 32767 @ 0x7fff
689 %0 = load i32, ptr %p, align 4
690 %shl = lshr i32 %0, 16
691 %and = and i32 %shl, 32767
692 store i32 %and, ptr %p, align 4
696 define arm_aapcscc void @test_shift8_mask24(ptr nocapture %p) {
697 ; CHECK-ARM-LABEL: test_shift8_mask24:
698 ; CHECK-ARM: @ %bb.0: @ %entry
699 ; CHECK-ARM-NEXT: ldr r1, [r0]
700 ; CHECK-ARM-NEXT: lsr r1, r1, #8
701 ; CHECK-ARM-NEXT: str r1, [r0]
702 ; CHECK-ARM-NEXT: bx lr
704 ; CHECK-BE-LABEL: test_shift8_mask24:
705 ; CHECK-BE: @ %bb.0: @ %entry
706 ; CHECK-BE-NEXT: ldr r1, [r0]
707 ; CHECK-BE-NEXT: lsr r1, r1, #8
708 ; CHECK-BE-NEXT: str r1, [r0]
709 ; CHECK-BE-NEXT: bx lr
711 ; CHECK-THUMB-LABEL: test_shift8_mask24:
712 ; CHECK-THUMB: @ %bb.0: @ %entry
713 ; CHECK-THUMB-NEXT: ldr r1, [r0]
714 ; CHECK-THUMB-NEXT: lsrs r1, r1, #8
715 ; CHECK-THUMB-NEXT: str r1, [r0]
716 ; CHECK-THUMB-NEXT: bx lr
718 ; CHECK-ALIGN-LABEL: test_shift8_mask24:
719 ; CHECK-ALIGN: @ %bb.0: @ %entry
720 ; CHECK-ALIGN-NEXT: ldr r1, [r0]
721 ; CHECK-ALIGN-NEXT: lsrs r1, r1, #8
722 ; CHECK-ALIGN-NEXT: str r1, [r0]
723 ; CHECK-ALIGN-NEXT: bx lr
725 ; CHECK-V6M-LABEL: test_shift8_mask24:
726 ; CHECK-V6M: @ %bb.0: @ %entry
727 ; CHECK-V6M-NEXT: ldr r1, [r0]
728 ; CHECK-V6M-NEXT: lsrs r1, r1, #8
729 ; CHECK-V6M-NEXT: str r1, [r0]
730 ; CHECK-V6M-NEXT: bx lr
732 %0 = load i32, ptr %p, align 4
733 %shl = lshr i32 %0, 8
734 %and = and i32 %shl, 16777215
735 store i32 %and, ptr %p, align 4
739 define arm_aapcscc void @test_shift24_mask16(ptr nocapture %p) {
740 ; CHECK-COMMON-LABEL: test_shift24_mask16:
741 ; CHECK-COMMON: @ %bb.0: @ %entry
742 ; CHECK-COMMON-NEXT: ldrb r1, [r0, #3]
743 ; CHECK-COMMON-NEXT: str r1, [r0]
744 ; CHECK-COMMON-NEXT: bx lr
746 ; CHECK-BE-LABEL: test_shift24_mask16:
747 ; CHECK-BE: @ %bb.0: @ %entry
748 ; CHECK-BE-NEXT: ldrb r1, [r0]
749 ; CHECK-BE-NEXT: str r1, [r0]
750 ; CHECK-BE-NEXT: bx lr
752 ; CHECK-V6M-LABEL: test_shift24_mask16:
753 ; CHECK-V6M: @ %bb.0: @ %entry
754 ; CHECK-V6M-NEXT: ldrb r1, [r0, #3]
755 ; CHECK-V6M-NEXT: str r1, [r0]
756 ; CHECK-V6M-NEXT: bx lr
758 %0 = load i32, ptr %p, align 4
759 %shl = lshr i32 %0, 24
760 %and = and i32 %shl, 65535
761 store i32 %and, ptr %p, align 4
765 define arm_aapcscc void @test_sext_shift8_mask8(ptr %p, ptr %q) {
766 ; CHECK-COMMON-LABEL: test_sext_shift8_mask8:
767 ; CHECK-COMMON: @ %bb.0: @ %entry
768 ; CHECK-COMMON-NEXT: ldrb r0, [r0, #1]
769 ; CHECK-COMMON-NEXT: str r0, [r1]
770 ; CHECK-COMMON-NEXT: bx lr
772 ; CHECK-BE-LABEL: test_sext_shift8_mask8:
773 ; CHECK-BE: @ %bb.0: @ %entry
774 ; CHECK-BE-NEXT: ldrb r0, [r0]
775 ; CHECK-BE-NEXT: str r0, [r1]
776 ; CHECK-BE-NEXT: bx lr
778 ; CHECK-V6M-LABEL: test_sext_shift8_mask8:
779 ; CHECK-V6M: @ %bb.0: @ %entry
780 ; CHECK-V6M-NEXT: ldrb r0, [r0, #1]
781 ; CHECK-V6M-NEXT: str r0, [r1]
782 ; CHECK-V6M-NEXT: bx lr
784 %0 = load i16, ptr %p, align 4
785 %1 = sext i16 %0 to i32
786 %shl = lshr i32 %1, 8
787 %and = and i32 %shl, 255
788 store i32 %and, ptr %q, align 4
792 define arm_aapcscc void @test_sext_shift8_mask16(ptr %p, ptr %q) {
793 ; CHECK-ARM-LABEL: test_sext_shift8_mask16:
794 ; CHECK-ARM: @ %bb.0: @ %entry
795 ; CHECK-ARM-NEXT: ldrsh r0, [r0]
796 ; CHECK-ARM-NEXT: ubfx r0, r0, #8, #16
797 ; CHECK-ARM-NEXT: str r0, [r1]
798 ; CHECK-ARM-NEXT: bx lr
800 ; CHECK-BE-LABEL: test_sext_shift8_mask16:
801 ; CHECK-BE: @ %bb.0: @ %entry
802 ; CHECK-BE-NEXT: ldrsh r0, [r0]
803 ; CHECK-BE-NEXT: ubfx r0, r0, #8, #16
804 ; CHECK-BE-NEXT: str r0, [r1]
805 ; CHECK-BE-NEXT: bx lr
807 ; CHECK-THUMB-LABEL: test_sext_shift8_mask16:
808 ; CHECK-THUMB: @ %bb.0: @ %entry
809 ; CHECK-THUMB-NEXT: ldrsh.w r0, [r0]
810 ; CHECK-THUMB-NEXT: ubfx r0, r0, #8, #16
811 ; CHECK-THUMB-NEXT: str r0, [r1]
812 ; CHECK-THUMB-NEXT: bx lr
814 ; CHECK-ALIGN-LABEL: test_sext_shift8_mask16:
815 ; CHECK-ALIGN: @ %bb.0: @ %entry
816 ; CHECK-ALIGN-NEXT: ldrsh.w r0, [r0]
817 ; CHECK-ALIGN-NEXT: ubfx r0, r0, #8, #16
818 ; CHECK-ALIGN-NEXT: str r0, [r1]
819 ; CHECK-ALIGN-NEXT: bx lr
821 ; CHECK-V6M-LABEL: test_sext_shift8_mask16:
822 ; CHECK-V6M: @ %bb.0: @ %entry
823 ; CHECK-V6M-NEXT: movs r2, #0
824 ; CHECK-V6M-NEXT: ldrsh r0, [r0, r2]
825 ; CHECK-V6M-NEXT: lsrs r0, r0, #8
826 ; CHECK-V6M-NEXT: uxth r0, r0
827 ; CHECK-V6M-NEXT: str r0, [r1]
828 ; CHECK-V6M-NEXT: bx lr
830 %0 = load i16, ptr %p, align 4
831 %1 = sext i16 %0 to i32
832 %shl = lshr i32 %1, 8
833 %and = and i32 %shl, 65535
834 store i32 %and, ptr %q, align 4
838 define i1 @trunc_i64_mask_srl(i32 zeroext %AttrArgNo, ptr %ptr) {
839 ; CHECK-ARM-LABEL: trunc_i64_mask_srl:
840 ; CHECK-ARM: @ %bb.0: @ %entry
841 ; CHECK-ARM-NEXT: ldrh r2, [r1, #4]
842 ; CHECK-ARM-NEXT: mov r1, #0
843 ; CHECK-ARM-NEXT: cmp r2, r0
844 ; CHECK-ARM-NEXT: movwhi r1, #1
845 ; CHECK-ARM-NEXT: mov r0, r1
846 ; CHECK-ARM-NEXT: bx lr
848 ; CHECK-BE-LABEL: trunc_i64_mask_srl:
849 ; CHECK-BE: @ %bb.0: @ %entry
850 ; CHECK-BE-NEXT: ldrh r2, [r1, #2]
851 ; CHECK-BE-NEXT: mov r1, #0
852 ; CHECK-BE-NEXT: cmp r2, r0
853 ; CHECK-BE-NEXT: movwhi r1, #1
854 ; CHECK-BE-NEXT: mov r0, r1
855 ; CHECK-BE-NEXT: bx lr
857 ; CHECK-THUMB-LABEL: trunc_i64_mask_srl:
858 ; CHECK-THUMB: @ %bb.0: @ %entry
859 ; CHECK-THUMB-NEXT: ldrh r2, [r1, #4]
860 ; CHECK-THUMB-NEXT: movs r1, #0
861 ; CHECK-THUMB-NEXT: cmp r2, r0
862 ; CHECK-THUMB-NEXT: it hi
863 ; CHECK-THUMB-NEXT: movhi r1, #1
864 ; CHECK-THUMB-NEXT: mov r0, r1
865 ; CHECK-THUMB-NEXT: bx lr
867 ; CHECK-ALIGN-LABEL: trunc_i64_mask_srl:
868 ; CHECK-ALIGN: @ %bb.0: @ %entry
869 ; CHECK-ALIGN-NEXT: ldrh r2, [r1, #4]
870 ; CHECK-ALIGN-NEXT: movs r1, #0
871 ; CHECK-ALIGN-NEXT: cmp r2, r0
872 ; CHECK-ALIGN-NEXT: it hi
873 ; CHECK-ALIGN-NEXT: movhi r1, #1
874 ; CHECK-ALIGN-NEXT: mov r0, r1
875 ; CHECK-ALIGN-NEXT: bx lr
877 ; CHECK-V6M-LABEL: trunc_i64_mask_srl:
878 ; CHECK-V6M: @ %bb.0: @ %entry
879 ; CHECK-V6M-NEXT: ldrh r1, [r1, #4]
880 ; CHECK-V6M-NEXT: cmp r1, r0
881 ; CHECK-V6M-NEXT: bhi .LBB26_2
882 ; CHECK-V6M-NEXT: @ %bb.1: @ %entry
883 ; CHECK-V6M-NEXT: movs r0, #0
884 ; CHECK-V6M-NEXT: bx lr
885 ; CHECK-V6M-NEXT: .LBB26_2:
886 ; CHECK-V6M-NEXT: movs r0, #1
887 ; CHECK-V6M-NEXT: bx lr
889 %bf.load.i = load i64, ptr %ptr, align 8
890 %bf.lshr.i = lshr i64 %bf.load.i, 32
891 %0 = trunc i64 %bf.lshr.i to i32
892 %bf.cast.i = and i32 %0, 65535
893 %cmp.i = icmp ugt i32 %bf.cast.i, %AttrArgNo
897 define i64 @or_tree_with_shifts_i64(i64 %a, i64 %b, i64 %c, i64 %d) {
898 ; CHECK-ARM-LABEL: or_tree_with_shifts_i64:
899 ; CHECK-ARM: @ %bb.0:
900 ; CHECK-ARM-NEXT: .save {r11, lr}
901 ; CHECK-ARM-NEXT: push {r11, lr}
902 ; CHECK-ARM-NEXT: ldr lr, [sp, #16]
903 ; CHECK-ARM-NEXT: orr r0, r0, r2, lsl #16
904 ; CHECK-ARM-NEXT: ldr r12, [sp, #8]
905 ; CHECK-ARM-NEXT: orr r3, lr, r3
906 ; CHECK-ARM-NEXT: orr r1, r1, r3, lsl #16
907 ; CHECK-ARM-NEXT: orr r1, r1, r2, lsr #16
908 ; CHECK-ARM-NEXT: orr r1, r1, r12
909 ; CHECK-ARM-NEXT: pop {r11, pc}
911 ; CHECK-BE-LABEL: or_tree_with_shifts_i64:
913 ; CHECK-BE-NEXT: .save {r11, lr}
914 ; CHECK-BE-NEXT: push {r11, lr}
915 ; CHECK-BE-NEXT: ldr lr, [sp, #20]
916 ; CHECK-BE-NEXT: orr r1, r1, r3, lsl #16
917 ; CHECK-BE-NEXT: ldr r12, [sp, #12]
918 ; CHECK-BE-NEXT: orr r2, lr, r2
919 ; CHECK-BE-NEXT: orr r0, r0, r2, lsl #16
920 ; CHECK-BE-NEXT: orr r0, r0, r3, lsr #16
921 ; CHECK-BE-NEXT: orr r0, r0, r12
922 ; CHECK-BE-NEXT: pop {r11, pc}
924 ; CHECK-ALIGN-LABEL: or_tree_with_shifts_i64:
925 ; CHECK-ALIGN: @ %bb.0:
926 ; CHECK-ALIGN-NEXT: ldr.w r12, [sp, #8]
927 ; CHECK-ALIGN-NEXT: orr.w r0, r0, r2, lsl #16
928 ; CHECK-ALIGN-NEXT: orr.w r3, r3, r12
929 ; CHECK-ALIGN-NEXT: orr.w r1, r1, r3, lsl #16
930 ; CHECK-ALIGN-NEXT: orr.w r1, r1, r2, lsr #16
931 ; CHECK-ALIGN-NEXT: ldr r2, [sp]
932 ; CHECK-ALIGN-NEXT: orrs r1, r2
933 ; CHECK-ALIGN-NEXT: bx lr
935 ; CHECK-V6M-LABEL: or_tree_with_shifts_i64:
936 ; CHECK-V6M: @ %bb.0:
937 ; CHECK-V6M-NEXT: push {r4, lr}
938 ; CHECK-V6M-NEXT: lsls r4, r2, #16
939 ; CHECK-V6M-NEXT: orrs r0, r4
940 ; CHECK-V6M-NEXT: ldr r4, [sp, #16]
941 ; CHECK-V6M-NEXT: orrs r4, r3
942 ; CHECK-V6M-NEXT: lsls r3, r4, #16
943 ; CHECK-V6M-NEXT: orrs r1, r3
944 ; CHECK-V6M-NEXT: lsrs r2, r2, #16
945 ; CHECK-V6M-NEXT: orrs r1, r2
946 ; CHECK-V6M-NEXT: ldr r2, [sp, #8]
947 ; CHECK-V6M-NEXT: orrs r1, r2
948 ; CHECK-V6M-NEXT: pop {r4, pc}
949 %b.shifted = shl i64 %b, 16
950 %c.shifted = shl i64 %c, 32
951 %d.shifted = shl i64 %d, 48
952 %or.ad = or i64 %a, %d.shifted
953 %or.adb = or i64 %or.ad, %b.shifted
954 %or.adbc = or i64 %or.adb, %c.shifted
958 define i32 @or_tree_with_shifts_i32(i32 %a, i32 %b, i32 %c, i32 %d) {
959 ; CHECK-ARM-LABEL: or_tree_with_shifts_i32:
960 ; CHECK-ARM: @ %bb.0:
961 ; CHECK-ARM-NEXT: orr r0, r0, r2
962 ; CHECK-ARM-NEXT: orr r0, r1, r0, lsl #16
963 ; CHECK-ARM-NEXT: orr r0, r0, r3
964 ; CHECK-ARM-NEXT: bx lr
966 ; CHECK-BE-LABEL: or_tree_with_shifts_i32:
968 ; CHECK-BE-NEXT: orr r0, r0, r2
969 ; CHECK-BE-NEXT: orr r0, r1, r0, lsl #16
970 ; CHECK-BE-NEXT: orr r0, r0, r3
971 ; CHECK-BE-NEXT: bx lr
973 ; CHECK-THUMB-LABEL: or_tree_with_shifts_i32:
974 ; CHECK-THUMB: @ %bb.0:
975 ; CHECK-THUMB-NEXT: orrs r0, r2
976 ; CHECK-THUMB-NEXT: orr.w r0, r1, r0, lsl #16
977 ; CHECK-THUMB-NEXT: orrs r0, r3
978 ; CHECK-THUMB-NEXT: bx lr
980 ; CHECK-ALIGN-LABEL: or_tree_with_shifts_i32:
981 ; CHECK-ALIGN: @ %bb.0:
982 ; CHECK-ALIGN-NEXT: orrs r0, r2
983 ; CHECK-ALIGN-NEXT: orr.w r0, r1, r0, lsl #16
984 ; CHECK-ALIGN-NEXT: orrs r0, r3
985 ; CHECK-ALIGN-NEXT: bx lr
987 ; CHECK-V6M-LABEL: or_tree_with_shifts_i32:
988 ; CHECK-V6M: @ %bb.0:
989 ; CHECK-V6M-NEXT: orrs r0, r2
990 ; CHECK-V6M-NEXT: lsls r0, r0, #16
991 ; CHECK-V6M-NEXT: orrs r0, r1
992 ; CHECK-V6M-NEXT: orrs r0, r3
993 ; CHECK-V6M-NEXT: bx lr
994 %a.shifted = shl i32 %a, 16
995 %c.shifted = shl i32 %c, 16
996 %or.ab = or i32 %a.shifted, %b
997 %or.cd = or i32 %c.shifted, %d
998 %r = or i32 %or.ab, %or.cd
1002 define i32 @xor_tree_with_shifts_i32(i32 %a, i32 %b, i32 %c, i32 %d) {
1003 ; CHECK-ARM-LABEL: xor_tree_with_shifts_i32:
1004 ; CHECK-ARM: @ %bb.0:
1005 ; CHECK-ARM-NEXT: eor r0, r0, r2
1006 ; CHECK-ARM-NEXT: eor r0, r1, r0, lsr #16
1007 ; CHECK-ARM-NEXT: eor r0, r0, r3
1008 ; CHECK-ARM-NEXT: bx lr
1010 ; CHECK-BE-LABEL: xor_tree_with_shifts_i32:
1011 ; CHECK-BE: @ %bb.0:
1012 ; CHECK-BE-NEXT: eor r0, r0, r2
1013 ; CHECK-BE-NEXT: eor r0, r1, r0, lsr #16
1014 ; CHECK-BE-NEXT: eor r0, r0, r3
1015 ; CHECK-BE-NEXT: bx lr
1017 ; CHECK-THUMB-LABEL: xor_tree_with_shifts_i32:
1018 ; CHECK-THUMB: @ %bb.0:
1019 ; CHECK-THUMB-NEXT: eors r0, r2
1020 ; CHECK-THUMB-NEXT: eor.w r0, r1, r0, lsr #16
1021 ; CHECK-THUMB-NEXT: eors r0, r3
1022 ; CHECK-THUMB-NEXT: bx lr
1024 ; CHECK-ALIGN-LABEL: xor_tree_with_shifts_i32:
1025 ; CHECK-ALIGN: @ %bb.0:
1026 ; CHECK-ALIGN-NEXT: eors r0, r2
1027 ; CHECK-ALIGN-NEXT: eor.w r0, r1, r0, lsr #16
1028 ; CHECK-ALIGN-NEXT: eors r0, r3
1029 ; CHECK-ALIGN-NEXT: bx lr
1031 ; CHECK-V6M-LABEL: xor_tree_with_shifts_i32:
1032 ; CHECK-V6M: @ %bb.0:
1033 ; CHECK-V6M-NEXT: eors r0, r2
1034 ; CHECK-V6M-NEXT: lsrs r0, r0, #16
1035 ; CHECK-V6M-NEXT: eors r0, r1
1036 ; CHECK-V6M-NEXT: eors r0, r3
1037 ; CHECK-V6M-NEXT: bx lr
1038 %a.shifted = lshr i32 %a, 16
1039 %c.shifted = lshr i32 %c, 16
1040 %xor.ab = xor i32 %a.shifted, %b
1041 %xor.cd = xor i32 %d, %c.shifted
1042 %r = xor i32 %xor.ab, %xor.cd
1046 define i32 @and_tree_with_shifts_i32(i32 %a, i32 %b, i32 %c, i32 %d) {
1047 ; CHECK-ARM-LABEL: and_tree_with_shifts_i32:
1048 ; CHECK-ARM: @ %bb.0:
1049 ; CHECK-ARM-NEXT: and r0, r0, r2
1050 ; CHECK-ARM-NEXT: and r0, r1, r0, asr #16
1051 ; CHECK-ARM-NEXT: and r0, r0, r3
1052 ; CHECK-ARM-NEXT: bx lr
1054 ; CHECK-BE-LABEL: and_tree_with_shifts_i32:
1055 ; CHECK-BE: @ %bb.0:
1056 ; CHECK-BE-NEXT: and r0, r0, r2
1057 ; CHECK-BE-NEXT: and r0, r1, r0, asr #16
1058 ; CHECK-BE-NEXT: and r0, r0, r3
1059 ; CHECK-BE-NEXT: bx lr
1061 ; CHECK-THUMB-LABEL: and_tree_with_shifts_i32:
1062 ; CHECK-THUMB: @ %bb.0:
1063 ; CHECK-THUMB-NEXT: ands r0, r2
1064 ; CHECK-THUMB-NEXT: and.w r0, r1, r0, asr #16
1065 ; CHECK-THUMB-NEXT: ands r0, r3
1066 ; CHECK-THUMB-NEXT: bx lr
1068 ; CHECK-ALIGN-LABEL: and_tree_with_shifts_i32:
1069 ; CHECK-ALIGN: @ %bb.0:
1070 ; CHECK-ALIGN-NEXT: ands r0, r2
1071 ; CHECK-ALIGN-NEXT: and.w r0, r1, r0, asr #16
1072 ; CHECK-ALIGN-NEXT: ands r0, r3
1073 ; CHECK-ALIGN-NEXT: bx lr
1075 ; CHECK-V6M-LABEL: and_tree_with_shifts_i32:
1076 ; CHECK-V6M: @ %bb.0:
1077 ; CHECK-V6M-NEXT: ands r0, r2
1078 ; CHECK-V6M-NEXT: asrs r0, r0, #16
1079 ; CHECK-V6M-NEXT: ands r0, r1
1080 ; CHECK-V6M-NEXT: ands r0, r3
1081 ; CHECK-V6M-NEXT: bx lr
1082 %a.shifted = ashr i32 %a, 16
1083 %c.shifted = ashr i32 %c, 16
1084 %and.ab = and i32 %b, %a.shifted
1085 %and.cd = and i32 %c.shifted, %d
1086 %r = and i32 %and.ab, %and.cd
1090 define i32 @logic_tree_with_shifts_var_i32(i32 %a, i32 %b, i32 %c, i32 %d, i32 %s) {
1091 ; CHECK-ARM-LABEL: logic_tree_with_shifts_var_i32:
1092 ; CHECK-ARM: @ %bb.0:
1093 ; CHECK-ARM-NEXT: ldr r12, [sp]
1094 ; CHECK-ARM-NEXT: orr r0, r0, r2
1095 ; CHECK-ARM-NEXT: orr r0, r1, r0, lsl r12
1096 ; CHECK-ARM-NEXT: orr r0, r0, r3
1097 ; CHECK-ARM-NEXT: bx lr
1099 ; CHECK-BE-LABEL: logic_tree_with_shifts_var_i32:
1100 ; CHECK-BE: @ %bb.0:
1101 ; CHECK-BE-NEXT: ldr r12, [sp]
1102 ; CHECK-BE-NEXT: orr r0, r0, r2
1103 ; CHECK-BE-NEXT: orr r0, r1, r0, lsl r12
1104 ; CHECK-BE-NEXT: orr r0, r0, r3
1105 ; CHECK-BE-NEXT: bx lr
1107 ; CHECK-ALIGN-LABEL: logic_tree_with_shifts_var_i32:
1108 ; CHECK-ALIGN: @ %bb.0:
1109 ; CHECK-ALIGN-NEXT: orrs r0, r2
1110 ; CHECK-ALIGN-NEXT: ldr r2, [sp]
1111 ; CHECK-ALIGN-NEXT: lsls r0, r2
1112 ; CHECK-ALIGN-NEXT: orrs r0, r1
1113 ; CHECK-ALIGN-NEXT: orrs r0, r3
1114 ; CHECK-ALIGN-NEXT: bx lr
1116 ; CHECK-V6M-LABEL: logic_tree_with_shifts_var_i32:
1117 ; CHECK-V6M: @ %bb.0:
1118 ; CHECK-V6M-NEXT: orrs r0, r2
1119 ; CHECK-V6M-NEXT: ldr r2, [sp]
1120 ; CHECK-V6M-NEXT: lsls r0, r2
1121 ; CHECK-V6M-NEXT: orrs r0, r1
1122 ; CHECK-V6M-NEXT: orrs r0, r3
1123 ; CHECK-V6M-NEXT: bx lr
1124 %a.shifted = shl i32 %a, %s
1125 %c.shifted = shl i32 %c, %s
1126 %or.ab = or i32 %b, %a.shifted
1127 %or.cd = or i32 %d, %c.shifted
1128 %r = or i32 %or.ab, %or.cd
1132 define i32 @logic_tree_with_mismatching_shifts_i32(i32 %a, i32 %b, i32 %c, i32 %d) {
1133 ; CHECK-ARM-LABEL: logic_tree_with_mismatching_shifts_i32:
1134 ; CHECK-ARM: @ %bb.0:
1135 ; CHECK-ARM-NEXT: orr r2, r3, r2, lsl #16
1136 ; CHECK-ARM-NEXT: orr r0, r1, r0, lsl #15
1137 ; CHECK-ARM-NEXT: orr r0, r0, r2
1138 ; CHECK-ARM-NEXT: bx lr
1140 ; CHECK-BE-LABEL: logic_tree_with_mismatching_shifts_i32:
1141 ; CHECK-BE: @ %bb.0:
1142 ; CHECK-BE-NEXT: orr r2, r3, r2, lsl #16
1143 ; CHECK-BE-NEXT: orr r0, r1, r0, lsl #15
1144 ; CHECK-BE-NEXT: orr r0, r0, r2
1145 ; CHECK-BE-NEXT: bx lr
1147 ; CHECK-THUMB-LABEL: logic_tree_with_mismatching_shifts_i32:
1148 ; CHECK-THUMB: @ %bb.0:
1149 ; CHECK-THUMB-NEXT: orr.w r2, r3, r2, lsl #16
1150 ; CHECK-THUMB-NEXT: orr.w r0, r1, r0, lsl #15
1151 ; CHECK-THUMB-NEXT: orrs r0, r2
1152 ; CHECK-THUMB-NEXT: bx lr
1154 ; CHECK-ALIGN-LABEL: logic_tree_with_mismatching_shifts_i32:
1155 ; CHECK-ALIGN: @ %bb.0:
1156 ; CHECK-ALIGN-NEXT: orr.w r2, r3, r2, lsl #16
1157 ; CHECK-ALIGN-NEXT: orr.w r0, r1, r0, lsl #15
1158 ; CHECK-ALIGN-NEXT: orrs r0, r2
1159 ; CHECK-ALIGN-NEXT: bx lr
1161 ; CHECK-V6M-LABEL: logic_tree_with_mismatching_shifts_i32:
1162 ; CHECK-V6M: @ %bb.0:
1163 ; CHECK-V6M-NEXT: lsls r2, r2, #16
1164 ; CHECK-V6M-NEXT: orrs r2, r3
1165 ; CHECK-V6M-NEXT: lsls r0, r0, #15
1166 ; CHECK-V6M-NEXT: orrs r0, r1
1167 ; CHECK-V6M-NEXT: orrs r0, r2
1168 ; CHECK-V6M-NEXT: bx lr
1169 %a.shifted = shl i32 %a, 15
1170 %c.shifted = shl i32 %c, 16
1171 %or.ab = or i32 %a.shifted, %b
1172 %or.cd = or i32 %c.shifted, %d
1173 %r = or i32 %or.ab, %or.cd
1177 define i32 @logic_tree_with_mismatching_shifts2_i32(i32 %a, i32 %b, i32 %c, i32 %d) {
1178 ; CHECK-ARM-LABEL: logic_tree_with_mismatching_shifts2_i32:
1179 ; CHECK-ARM: @ %bb.0:
1180 ; CHECK-ARM-NEXT: orr r2, r3, r2, lsr #16
1181 ; CHECK-ARM-NEXT: orr r0, r1, r0, lsl #16
1182 ; CHECK-ARM-NEXT: orr r0, r0, r2
1183 ; CHECK-ARM-NEXT: bx lr
1185 ; CHECK-BE-LABEL: logic_tree_with_mismatching_shifts2_i32:
1186 ; CHECK-BE: @ %bb.0:
1187 ; CHECK-BE-NEXT: orr r2, r3, r2, lsr #16
1188 ; CHECK-BE-NEXT: orr r0, r1, r0, lsl #16
1189 ; CHECK-BE-NEXT: orr r0, r0, r2
1190 ; CHECK-BE-NEXT: bx lr
1192 ; CHECK-THUMB-LABEL: logic_tree_with_mismatching_shifts2_i32:
1193 ; CHECK-THUMB: @ %bb.0:
1194 ; CHECK-THUMB-NEXT: orr.w r2, r3, r2, lsr #16
1195 ; CHECK-THUMB-NEXT: orr.w r0, r1, r0, lsl #16
1196 ; CHECK-THUMB-NEXT: orrs r0, r2
1197 ; CHECK-THUMB-NEXT: bx lr
1199 ; CHECK-ALIGN-LABEL: logic_tree_with_mismatching_shifts2_i32:
1200 ; CHECK-ALIGN: @ %bb.0:
1201 ; CHECK-ALIGN-NEXT: orr.w r2, r3, r2, lsr #16
1202 ; CHECK-ALIGN-NEXT: orr.w r0, r1, r0, lsl #16
1203 ; CHECK-ALIGN-NEXT: orrs r0, r2
1204 ; CHECK-ALIGN-NEXT: bx lr
1206 ; CHECK-V6M-LABEL: logic_tree_with_mismatching_shifts2_i32:
1207 ; CHECK-V6M: @ %bb.0:
1208 ; CHECK-V6M-NEXT: lsrs r2, r2, #16
1209 ; CHECK-V6M-NEXT: orrs r2, r3
1210 ; CHECK-V6M-NEXT: lsls r0, r0, #16
1211 ; CHECK-V6M-NEXT: orrs r0, r1
1212 ; CHECK-V6M-NEXT: orrs r0, r2
1213 ; CHECK-V6M-NEXT: bx lr
1214 %a.shifted = shl i32 %a, 16
1215 %c.shifted = lshr i32 %c, 16
1216 %or.ab = or i32 %a.shifted, %b
1217 %or.cd = or i32 %c.shifted, %d
1218 %r = or i32 %or.ab, %or.cd
1222 define <4 x i32> @or_tree_with_shifts_vec_i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i32> %d) {
1223 ; CHECK-ARM-LABEL: or_tree_with_shifts_vec_i32:
1224 ; CHECK-ARM: @ %bb.0:
1225 ; CHECK-ARM-NEXT: vorr q8, q0, q2
1226 ; CHECK-ARM-NEXT: vshl.i32 q8, q8, #16
1227 ; CHECK-ARM-NEXT: vorr q8, q8, q1
1228 ; CHECK-ARM-NEXT: vorr q0, q8, q3
1229 ; CHECK-ARM-NEXT: bx lr
1231 ; CHECK-BE-LABEL: or_tree_with_shifts_vec_i32:
1232 ; CHECK-BE: @ %bb.0:
1233 ; CHECK-BE-NEXT: vrev64.32 q8, q2
1234 ; CHECK-BE-NEXT: vrev64.32 q9, q0
1235 ; CHECK-BE-NEXT: vorr q8, q9, q8
1236 ; CHECK-BE-NEXT: vrev64.32 q9, q1
1237 ; CHECK-BE-NEXT: vrev64.32 q10, q3
1238 ; CHECK-BE-NEXT: vshl.i32 q8, q8, #16
1239 ; CHECK-BE-NEXT: vorr q8, q8, q9
1240 ; CHECK-BE-NEXT: vorr q8, q8, q10
1241 ; CHECK-BE-NEXT: vrev64.32 q0, q8
1242 ; CHECK-BE-NEXT: bx lr
1243 %a.shifted = shl <4 x i32> %a, <i32 16, i32 16, i32 16, i32 16>
1244 %c.shifted = shl <4 x i32> %c, <i32 16, i32 16, i32 16, i32 16>
1245 %or.ab = or <4 x i32> %a.shifted, %b
1246 %or.cd = or <4 x i32> %c.shifted, %d
1247 %r = or <4 x i32> %or.ab, %or.cd
1251 define <4 x i32> @or_tree_with_mismatching_shifts_vec_i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i32> %d) {
1252 ; CHECK-ARM-LABEL: or_tree_with_mismatching_shifts_vec_i32:
1253 ; CHECK-ARM: @ %bb.0:
1254 ; CHECK-ARM-NEXT: vshl.i32 q8, q2, #17
1255 ; CHECK-ARM-NEXT: vshl.i32 q9, q0, #16
1256 ; CHECK-ARM-NEXT: vorr q8, q8, q3
1257 ; CHECK-ARM-NEXT: vorr q9, q9, q1
1258 ; CHECK-ARM-NEXT: vorr q0, q9, q8
1259 ; CHECK-ARM-NEXT: bx lr
1261 ; CHECK-BE-LABEL: or_tree_with_mismatching_shifts_vec_i32:
1262 ; CHECK-BE: @ %bb.0:
1263 ; CHECK-BE-NEXT: vrev64.32 q8, q2
1264 ; CHECK-BE-NEXT: vrev64.32 q9, q0
1265 ; CHECK-BE-NEXT: vshl.i32 q8, q8, #17
1266 ; CHECK-BE-NEXT: vrev64.32 q10, q3
1267 ; CHECK-BE-NEXT: vshl.i32 q9, q9, #16
1268 ; CHECK-BE-NEXT: vrev64.32 q11, q1
1269 ; CHECK-BE-NEXT: vorr q8, q8, q10
1270 ; CHECK-BE-NEXT: vorr q9, q9, q11
1271 ; CHECK-BE-NEXT: vorr q8, q9, q8
1272 ; CHECK-BE-NEXT: vrev64.32 q0, q8
1273 ; CHECK-BE-NEXT: bx lr
1274 %a.shifted = shl <4 x i32> %a, <i32 16, i32 16, i32 16, i32 16>
1275 %c.shifted = shl <4 x i32> %c, <i32 17, i32 17, i32 17, i32 17>
1276 %or.ab = or <4 x i32> %a.shifted, %b
1277 %or.cd = or <4 x i32> %c.shifted, %d
1278 %r = or <4 x i32> %or.ab, %or.cd