1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64 -o - | FileCheck %s
3 ; RUN: llc < %s -mtriple=aarch64_be -o - | FileCheck %s --check-prefix=CHECKBE
5 define i64 @load32_and16_and(ptr %p, i64 %y) {
6 ; CHECK-LABEL: load32_and16_and:
8 ; CHECK-NEXT: ldr w8, [x0]
9 ; CHECK-NEXT: and w8, w1, w8
10 ; CHECK-NEXT: and x0, x8, #0xffff
13 ; CHECKBE-LABEL: load32_and16_and:
15 ; CHECKBE-NEXT: ldr w8, [x0]
16 ; CHECKBE-NEXT: and w8, w1, w8
17 ; CHECKBE-NEXT: and x0, x8, #0xffff
19 %x = load i32, ptr %p, align 4
20 %xz = zext i32 %x to i64
21 %ym = and i64 %y, 65535
26 define i64 @load32_and16_andr(ptr %p, i64 %y) {
27 ; CHECK-LABEL: load32_and16_andr:
29 ; CHECK-NEXT: ldr w8, [x0]
30 ; CHECK-NEXT: and w8, w1, w8
31 ; CHECK-NEXT: and x0, x8, #0xffff
34 ; CHECKBE-LABEL: load32_and16_andr:
36 ; CHECKBE-NEXT: ldr w8, [x0]
37 ; CHECKBE-NEXT: and w8, w1, w8
38 ; CHECKBE-NEXT: and x0, x8, #0xffff
40 %x = load i32, ptr %p, align 4
41 %xz = zext i32 %x to i64
43 %r = and i64 %a, 65535
47 define i64 @load32_and16_and_sext(ptr %p, i64 %y) {
48 ; CHECK-LABEL: load32_and16_and_sext:
50 ; CHECK-NEXT: ldr w8, [x0]
51 ; CHECK-NEXT: and w8, w1, w8
52 ; CHECK-NEXT: and x0, x8, #0xffff
55 ; CHECKBE-LABEL: load32_and16_and_sext:
57 ; CHECKBE-NEXT: ldr w8, [x0]
58 ; CHECKBE-NEXT: and w8, w1, w8
59 ; CHECKBE-NEXT: and x0, x8, #0xffff
61 %x = load i32, ptr %p, align 4
62 %xz = sext i32 %x to i64
64 %r = and i64 %a, 65535
68 define i64 @load32_and16_or(ptr %p, i64 %y) {
69 ; CHECK-LABEL: load32_and16_or:
71 ; CHECK-NEXT: ldr w8, [x0]
72 ; CHECK-NEXT: orr w8, w1, w8
73 ; CHECK-NEXT: and x0, x8, #0xffff
76 ; CHECKBE-LABEL: load32_and16_or:
78 ; CHECKBE-NEXT: ldr w8, [x0]
79 ; CHECKBE-NEXT: orr w8, w1, w8
80 ; CHECKBE-NEXT: and x0, x8, #0xffff
82 %x = load i32, ptr %p, align 4
83 %xz = zext i32 %x to i64
85 %r = and i64 %a, 65535
89 define i64 @load32_and16_orr(ptr %p, i64 %y) {
90 ; CHECK-LABEL: load32_and16_orr:
92 ; CHECK-NEXT: ldr w8, [x0]
93 ; CHECK-NEXT: and x9, x1, #0xffff
94 ; CHECK-NEXT: orr x0, x9, x8
97 ; CHECKBE-LABEL: load32_and16_orr:
99 ; CHECKBE-NEXT: ldr w8, [x0]
100 ; CHECKBE-NEXT: and x9, x1, #0xffff
101 ; CHECKBE-NEXT: orr x0, x9, x8
103 %x = load i32, ptr %p, align 4
104 %xz = zext i32 %x to i64
105 %ym = and i64 %y, 65535
110 define i64 @load32_and16_xorm1(ptr %p) {
111 ; CHECK-LABEL: load32_and16_xorm1:
113 ; CHECK-NEXT: ldr w8, [x0]
114 ; CHECK-NEXT: mvn w8, w8
115 ; CHECK-NEXT: and x0, x8, #0xffff
118 ; CHECKBE-LABEL: load32_and16_xorm1:
120 ; CHECKBE-NEXT: ldr w8, [x0]
121 ; CHECKBE-NEXT: mvn w8, w8
122 ; CHECKBE-NEXT: and x0, x8, #0xffff
124 %x = load i32, ptr %p, align 4
125 %xz = zext i32 %x to i64
127 %r = and i64 %a, 65535
131 define i64 @load64_and16(ptr %p, i128 %y) {
132 ; CHECK-LABEL: load64_and16:
134 ; CHECK-NEXT: ldrh w8, [x0]
135 ; CHECK-NEXT: and x0, x2, x8
138 ; CHECKBE-LABEL: load64_and16:
140 ; CHECKBE-NEXT: ldrh w8, [x0, #6]
141 ; CHECKBE-NEXT: and x0, x3, x8
143 %x = load i64, ptr %p, align 4
144 %xz = zext i64 %x to i128
145 %a = and i128 %y, %xz
146 %t = trunc i128 %a to i64
147 %r = and i64 %t, 65535
151 define i64 @load16_and16(ptr %p, i64 %y) {
152 ; CHECK-LABEL: load16_and16:
154 ; CHECK-NEXT: ldrh w8, [x0]
155 ; CHECK-NEXT: and x0, x1, x8
158 ; CHECKBE-LABEL: load16_and16:
160 ; CHECKBE-NEXT: ldrh w8, [x0]
161 ; CHECKBE-NEXT: and x0, x1, x8
163 %x = load i16, ptr %p, align 4
164 %xz = zext i16 %x to i64
166 %r = and i64 %a, 65535
170 define i64 @load16_and8(ptr %p, i64 %y) {
171 ; CHECK-LABEL: load16_and8:
173 ; CHECK-NEXT: ldrh w8, [x0]
174 ; CHECK-NEXT: and w8, w1, w8
175 ; CHECK-NEXT: and x0, x8, #0xff
178 ; CHECKBE-LABEL: load16_and8:
180 ; CHECKBE-NEXT: ldrh w8, [x0]
181 ; CHECKBE-NEXT: and w8, w1, w8
182 ; CHECKBE-NEXT: and x0, x8, #0xff
184 %x = load i16, ptr %p, align 4
185 %xz = zext i16 %x to i64
191 define i64 @load16_and7(ptr %p, i64 %y) {
192 ; CHECK-LABEL: load16_and7:
194 ; CHECK-NEXT: ldrh w8, [x0]
195 ; CHECK-NEXT: and w8, w1, w8
196 ; CHECK-NEXT: and x0, x8, #0x7f
199 ; CHECKBE-LABEL: load16_and7:
201 ; CHECKBE-NEXT: ldrh w8, [x0]
202 ; CHECKBE-NEXT: and w8, w1, w8
203 ; CHECKBE-NEXT: and x0, x8, #0x7f
205 %x = load i16, ptr %p, align 4
206 %xz = zext i16 %x to i64
212 define i64 @load8_and16(ptr %p, i64 %y) {
213 ; CHECK-LABEL: load8_and16:
215 ; CHECK-NEXT: ldrb w8, [x0]
216 ; CHECK-NEXT: and x0, x1, x8
219 ; CHECKBE-LABEL: load8_and16:
221 ; CHECKBE-NEXT: ldrb w8, [x0]
222 ; CHECKBE-NEXT: and x0, x1, x8
224 %x = load i8, ptr %p, align 4
225 %xz = zext i8 %x to i64
227 %r = and i64 %a, 65535
231 define i64 @load8_and16_zext(ptr %p, i8 %y) {
232 ; CHECK-LABEL: load8_and16_zext:
234 ; CHECK-NEXT: ldrb w8, [x0]
235 ; CHECK-NEXT: and w8, w1, w8
236 ; CHECK-NEXT: and x0, x8, #0xff
239 ; CHECKBE-LABEL: load8_and16_zext:
241 ; CHECKBE-NEXT: ldrb w8, [x0]
242 ; CHECKBE-NEXT: and w8, w1, w8
243 ; CHECKBE-NEXT: and x0, x8, #0xff
245 %x = load i8, ptr %p, align 4
246 %xz = zext i8 %x to i64
247 %yz = zext i8 %y to i64
248 %a = and i64 %yz, %xz
249 %r = and i64 %a, 65535
253 define i64 @load8_and16_sext(ptr %p, i8 %y) {
254 ; CHECK-LABEL: load8_and16_sext:
256 ; CHECK-NEXT: ldrb w8, [x0]
257 ; CHECK-NEXT: // kill: def $w1 killed $w1 def $x1
258 ; CHECK-NEXT: and x0, x1, x8
261 ; CHECKBE-LABEL: load8_and16_sext:
263 ; CHECKBE-NEXT: ldrb w8, [x0]
264 ; CHECKBE-NEXT: // kill: def $w1 killed $w1 def $x1
265 ; CHECKBE-NEXT: and x0, x1, x8
267 %x = load i8, ptr %p, align 4
268 %xz = zext i8 %x to i64
269 %yz = sext i8 %y to i64
270 %a = and i64 %yz, %xz
271 %r = and i64 %a, 65535
275 define i64 @load8_and16_or(ptr %p, i64 %y) {
276 ; CHECK-LABEL: load8_and16_or:
278 ; CHECK-NEXT: ldrb w8, [x0]
279 ; CHECK-NEXT: orr w8, w1, w8
280 ; CHECK-NEXT: and x0, x8, #0xffff
283 ; CHECKBE-LABEL: load8_and16_or:
285 ; CHECKBE-NEXT: ldrb w8, [x0]
286 ; CHECKBE-NEXT: orr w8, w1, w8
287 ; CHECKBE-NEXT: and x0, x8, #0xffff
289 %x = load i8, ptr %p, align 4
290 %xz = zext i8 %x to i64
292 %r = and i64 %a, 65535
296 define i64 @load16_and8_manyext(ptr %p, i32 %y) {
297 ; CHECK-LABEL: load16_and8_manyext:
299 ; CHECK-NEXT: ldrh w8, [x0]
300 ; CHECK-NEXT: and w8, w1, w8
301 ; CHECK-NEXT: and x0, x8, #0xff
304 ; CHECKBE-LABEL: load16_and8_manyext:
306 ; CHECKBE-NEXT: ldrh w8, [x0]
307 ; CHECKBE-NEXT: and w8, w1, w8
308 ; CHECKBE-NEXT: and x0, x8, #0xff
310 %x = load i16, ptr %p, align 4
311 %xz = zext i16 %x to i32
313 %az = zext i32 %a to i64
314 %r = and i64 %az, 255
318 define i64 @multiple_load(ptr %p, ptr %q) {
319 ; CHECK-LABEL: multiple_load:
321 ; CHECK-NEXT: ldrh w8, [x0]
322 ; CHECK-NEXT: ldr w9, [x1]
323 ; CHECK-NEXT: and w8, w9, w8
324 ; CHECK-NEXT: and x0, x8, #0xff
327 ; CHECKBE-LABEL: multiple_load:
329 ; CHECKBE-NEXT: ldrh w8, [x0]
330 ; CHECKBE-NEXT: ldr w9, [x1]
331 ; CHECKBE-NEXT: and w8, w9, w8
332 ; CHECKBE-NEXT: and x0, x8, #0xff
334 %x = load i16, ptr %p, align 4
335 %xz = zext i16 %x to i64
336 %y = load i32, ptr %q, align 4
337 %yz = zext i32 %y to i64
338 %a = and i64 %yz, %xz
343 define i64 @multiple_load_or(ptr %p, ptr %q) {
344 ; CHECK-LABEL: multiple_load_or:
346 ; CHECK-NEXT: ldrh w8, [x0]
347 ; CHECK-NEXT: ldr w9, [x1]
348 ; CHECK-NEXT: orr w8, w9, w8
349 ; CHECK-NEXT: and x0, x8, #0xff
352 ; CHECKBE-LABEL: multiple_load_or:
354 ; CHECKBE-NEXT: ldrh w8, [x0]
355 ; CHECKBE-NEXT: ldr w9, [x1]
356 ; CHECKBE-NEXT: orr w8, w9, w8
357 ; CHECKBE-NEXT: and x0, x8, #0xff
359 %x = load i16, ptr %p, align 4
360 %xz = zext i16 %x to i64
361 %y = load i32, ptr %q, align 4
362 %yz = zext i32 %y to i64
368 define i64 @load32_and16_zexty(ptr %p, i32 %y) {
369 ; CHECK-LABEL: load32_and16_zexty:
371 ; CHECK-NEXT: ldr w8, [x0]
372 ; CHECK-NEXT: orr w8, w1, w8
373 ; CHECK-NEXT: and x0, x8, #0xffff
376 ; CHECKBE-LABEL: load32_and16_zexty:
378 ; CHECKBE-NEXT: ldr w8, [x0]
379 ; CHECKBE-NEXT: orr w8, w1, w8
380 ; CHECKBE-NEXT: and x0, x8, #0xffff
382 %x = load i32, ptr %p, align 4
383 %xz = zext i32 %x to i64
384 %yz = zext i32 %y to i64
386 %r = and i64 %a, 65535
390 define i64 @load32_and16_sexty(ptr %p, i32 %y) {
391 ; CHECK-LABEL: load32_and16_sexty:
393 ; CHECK-NEXT: ldr w8, [x0]
394 ; CHECK-NEXT: orr w8, w1, w8
395 ; CHECK-NEXT: and x0, x8, #0xffff
398 ; CHECKBE-LABEL: load32_and16_sexty:
400 ; CHECKBE-NEXT: ldr w8, [x0]
401 ; CHECKBE-NEXT: orr w8, w1, w8
402 ; CHECKBE-NEXT: and x0, x8, #0xffff
404 %x = load i32, ptr %p, align 4
405 %xz = zext i32 %x to i64
406 %yz = sext i32 %y to i64
408 %r = and i64 %a, 65535
412 define zeroext i1 @bigger(ptr nocapture readonly %c, ptr nocapture readonly %e, i64 %d, i64 %p1) {
413 ; CHECK-LABEL: bigger:
414 ; CHECK: // %bb.0: // %entry
415 ; CHECK-NEXT: ldrb w8, [x1, x2]
416 ; CHECK-NEXT: ldrb w9, [x0, x2]
417 ; CHECK-NEXT: and w10, w3, #0x7
418 ; CHECK-NEXT: mov w11, #8 // =0x8
419 ; CHECK-NEXT: sub w10, w11, w10
420 ; CHECK-NEXT: eor w8, w8, w9
421 ; CHECK-NEXT: mov w9, #5 // =0x5
422 ; CHECK-NEXT: lsr w8, w8, w10
423 ; CHECK-NEXT: tst w8, w9
424 ; CHECK-NEXT: cset w0, eq
427 ; CHECKBE-LABEL: bigger:
428 ; CHECKBE: // %bb.0: // %entry
429 ; CHECKBE-NEXT: ldrb w8, [x1, x2]
430 ; CHECKBE-NEXT: ldrb w9, [x0, x2]
431 ; CHECKBE-NEXT: and w10, w3, #0x7
432 ; CHECKBE-NEXT: mov w11, #8 // =0x8
433 ; CHECKBE-NEXT: sub w10, w11, w10
434 ; CHECKBE-NEXT: eor w8, w8, w9
435 ; CHECKBE-NEXT: mov w9, #5 // =0x5
436 ; CHECKBE-NEXT: lsr w8, w8, w10
437 ; CHECKBE-NEXT: tst w8, w9
438 ; CHECKBE-NEXT: cset w0, eq
441 %0 = trunc i64 %p1 to i16
443 %sh_prom = sub nuw nsw i16 8, %1
444 %shl = shl nuw nsw i16 5, %sh_prom
445 %arrayidx = getelementptr inbounds i8, ptr %c, i64 %d
446 %2 = load i8, ptr %arrayidx, align 1
447 %3 = and i16 %shl, 255
448 %conv2 = zext i16 %3 to i32
449 %arrayidx3 = getelementptr inbounds i8, ptr %e, i64 %d
450 %4 = load i8, ptr %arrayidx3, align 1
452 %6 = zext i8 %5 to i32
453 %7 = and i32 %6, %conv2
454 %cmp.not = icmp eq i32 %7, 0