1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O2 < %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefix=CHECKN
3 ; RUN: llc -O2 < %s -mtriple=aarch64-linux-gnu -mattr=strict-align | FileCheck %s --check-prefix=CHECKS
5 declare i32 @bcmp(ptr, ptr, i64) nounwind readonly
6 declare i32 @memcmp(ptr, ptr, i64) nounwind readonly
8 define i1 @test_b2(ptr %s1, ptr %s2) {
9 ; CHECKN-LABEL: test_b2:
10 ; CHECKN: // %bb.0: // %entry
11 ; CHECKN-NEXT: ldr x8, [x0]
12 ; CHECKN-NEXT: ldr x9, [x1]
13 ; CHECKN-NEXT: ldur x10, [x0, #7]
14 ; CHECKN-NEXT: ldur x11, [x1, #7]
15 ; CHECKN-NEXT: cmp x8, x9
16 ; CHECKN-NEXT: ccmp x10, x11, #0, eq
17 ; CHECKN-NEXT: cset w0, eq
20 ; CHECKS-LABEL: test_b2:
21 ; CHECKS: // %bb.0: // %entry
22 ; CHECKS-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
23 ; CHECKS-NEXT: .cfi_def_cfa_offset 16
24 ; CHECKS-NEXT: .cfi_offset w30, -16
25 ; CHECKS-NEXT: mov w2, #15 // =0xf
26 ; CHECKS-NEXT: bl bcmp
27 ; CHECKS-NEXT: cmp w0, #0
28 ; CHECKS-NEXT: cset w0, eq
29 ; CHECKS-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
32 %bcmp = call i32 @bcmp(ptr %s1, ptr %s2, i64 15)
33 %ret = icmp eq i32 %bcmp, 0
37 ; TODO: Four loads should be within the limit, but the heuristic isn't implemented.
38 define i1 @test_b2_align8(ptr align 8 %s1, ptr align 8 %s2) {
39 ; CHECKN-LABEL: test_b2_align8:
40 ; CHECKN: // %bb.0: // %entry
41 ; CHECKN-NEXT: ldr x8, [x0]
42 ; CHECKN-NEXT: ldr x9, [x1]
43 ; CHECKN-NEXT: ldur x10, [x0, #7]
44 ; CHECKN-NEXT: ldur x11, [x1, #7]
45 ; CHECKN-NEXT: cmp x8, x9
46 ; CHECKN-NEXT: ccmp x10, x11, #0, eq
47 ; CHECKN-NEXT: cset w0, eq
50 ; CHECKS-LABEL: test_b2_align8:
51 ; CHECKS: // %bb.0: // %entry
52 ; CHECKS-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
53 ; CHECKS-NEXT: .cfi_def_cfa_offset 16
54 ; CHECKS-NEXT: .cfi_offset w30, -16
55 ; CHECKS-NEXT: mov w2, #15 // =0xf
56 ; CHECKS-NEXT: bl bcmp
57 ; CHECKS-NEXT: cmp w0, #0
58 ; CHECKS-NEXT: cset w0, eq
59 ; CHECKS-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
62 %bcmp = call i32 @bcmp(ptr %s1, ptr %s2, i64 15)
63 %ret = icmp eq i32 %bcmp, 0
67 define i1 @test_bs(ptr %s1, ptr %s2) optsize {
68 ; CHECKN-LABEL: test_bs:
69 ; CHECKN: // %bb.0: // %entry
70 ; CHECKN-NEXT: ldp x8, x11, [x1]
71 ; CHECKN-NEXT: ldr x12, [x0, #16]
72 ; CHECKN-NEXT: ldp x9, x10, [x0]
73 ; CHECKN-NEXT: ldr x13, [x1, #16]
74 ; CHECKN-NEXT: cmp x9, x8
75 ; CHECKN-NEXT: ldur x8, [x0, #23]
76 ; CHECKN-NEXT: ldur x9, [x1, #23]
77 ; CHECKN-NEXT: ccmp x10, x11, #0, eq
78 ; CHECKN-NEXT: ccmp x12, x13, #0, eq
79 ; CHECKN-NEXT: ccmp x8, x9, #0, eq
80 ; CHECKN-NEXT: cset w0, eq
83 ; CHECKS-LABEL: test_bs:
84 ; CHECKS: // %bb.0: // %entry
85 ; CHECKS-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
86 ; CHECKS-NEXT: .cfi_def_cfa_offset 16
87 ; CHECKS-NEXT: .cfi_offset w30, -16
88 ; CHECKS-NEXT: mov w2, #31 // =0x1f
89 ; CHECKS-NEXT: bl memcmp
90 ; CHECKS-NEXT: cmp w0, #0
91 ; CHECKS-NEXT: cset w0, eq
92 ; CHECKS-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
95 %memcmp = call i32 @memcmp(ptr %s1, ptr %s2, i64 31)
96 %ret = icmp eq i32 %memcmp, 0