1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s
3 ; RUN: llc -mtriple=aarch64-linux-gnu -stop-after=finalize-isel -o - %s | FileCheck --check-prefix=MIR %s
5 ; MIR-DAG: ![[DOMAIN:[0-9]+]] = distinct !{!{{[0-9]+}}, !"bax"}
6 ; MIR-DAG: ![[SCOPE0:[0-9]+]] = distinct !{!{{[0-9]+}}, ![[DOMAIN]], !"bax: %p"}
7 ; MIR-DAG: ![[SCOPE1:[0-9]+]] = distinct !{!{{[0-9]+}}, ![[DOMAIN]], !"bax: %q"}
8 ; MIR-DAG: ![[SET0:[0-9]+]] = !{![[SCOPE0]]}
9 ; MIR-DAG: ![[SET1:[0-9]+]] = !{![[SCOPE1]]}
11 ; MIR-LABEL: name: test_memcpy
12 ; MIR: %2:fpr128 = LDRQui %0, 1 :: (load (s128) from %ir.p1, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
13 ; MIR-NEXT: STRQui killed %2, %0, 0 :: (store (s128) into %ir.p0, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
14 define i32 @test_memcpy(i32* nocapture %p, i32* nocapture readonly %q) {
15 ; CHECK-LABEL: test_memcpy:
17 ; CHECK-NEXT: ldp w9, w10, [x1]
18 ; CHECK-NEXT: ldr q0, [x0, #16]
19 ; CHECK-NEXT: mov x8, x0
20 ; CHECK-NEXT: add w0, w9, w10
21 ; CHECK-NEXT: str q0, [x8]
23 %p0 = bitcast i32* %p to i8*
24 %add.ptr = getelementptr inbounds i32, i32* %p, i64 4
25 %p1 = bitcast i32* %add.ptr to i8*
26 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(16) %p0, i8* noundef nonnull align 4 dereferenceable(16) %p1, i64 16, i1 false), !alias.scope !2, !noalias !4
27 %v0 = load i32, i32* %q, align 4, !alias.scope !4, !noalias !2
28 %q1 = getelementptr inbounds i32, i32* %q, i64 1
29 %v1 = load i32, i32* %q1, align 4, !alias.scope !4, !noalias !2
30 %add = add i32 %v0, %v1
34 ; MIR-LABEL: name: test_memcpy_inline
35 ; MIR: %2:fpr128 = LDRQui %0, 1 :: (load (s128) from %ir.p1, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
36 ; MIR-NEXT: STRQui killed %2, %0, 0 :: (store (s128) into %ir.p0, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
37 define i32 @test_memcpy_inline(i32* nocapture %p, i32* nocapture readonly %q) {
38 ; CHECK-LABEL: test_memcpy_inline:
40 ; CHECK-NEXT: ldp w9, w10, [x1]
41 ; CHECK-NEXT: ldr q0, [x0, #16]
42 ; CHECK-NEXT: mov x8, x0
43 ; CHECK-NEXT: add w0, w9, w10
44 ; CHECK-NEXT: str q0, [x8]
46 %p0 = bitcast i32* %p to i8*
47 %add.ptr = getelementptr inbounds i32, i32* %p, i64 4
48 %p1 = bitcast i32* %add.ptr to i8*
49 tail call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(16) %p0, i8* noundef nonnull align 4 dereferenceable(16) %p1, i64 16, i1 false), !alias.scope !2, !noalias !4
50 %v0 = load i32, i32* %q, align 4, !alias.scope !4, !noalias !2
51 %q1 = getelementptr inbounds i32, i32* %q, i64 1
52 %v1 = load i32, i32* %q1, align 4, !alias.scope !4, !noalias !2
53 %add = add i32 %v0, %v1
57 ; MIR-LABEL: name: test_memmove
58 ; MIR: %2:fpr128 = LDRQui %0, 1 :: (load (s128) from %ir.p1, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
59 ; MIR-NEXT: STRQui killed %2, %0, 0 :: (store (s128) into %ir.p0, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
60 define i32 @test_memmove(i32* nocapture %p, i32* nocapture readonly %q) {
61 ; CHECK-LABEL: test_memmove:
63 ; CHECK-NEXT: ldp w9, w10, [x1]
64 ; CHECK-NEXT: ldr q0, [x0, #16]
65 ; CHECK-NEXT: mov x8, x0
66 ; CHECK-NEXT: add w0, w9, w10
67 ; CHECK-NEXT: str q0, [x8]
69 %p0 = bitcast i32* %p to i8*
70 %add.ptr = getelementptr inbounds i32, i32* %p, i64 4
71 %p1 = bitcast i32* %add.ptr to i8*
72 tail call void @llvm.memmove.p0i8.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(16) %p0, i8* noundef nonnull align 4 dereferenceable(16) %p1, i64 16, i1 false), !alias.scope !2, !noalias !4
73 %v0 = load i32, i32* %q, align 4, !alias.scope !4, !noalias !2
74 %q1 = getelementptr inbounds i32, i32* %q, i64 1
75 %v1 = load i32, i32* %q1, align 4, !alias.scope !4, !noalias !2
76 %add = add i32 %v0, %v1
80 ; MIR-LABEL: name: test_memset
81 ; MIR: %2:gpr64 = MOVi64imm -6148914691236517206
82 ; MIR-NEXT: STRXui %2, %0, 1 :: (store (s64) into %ir.p0 + 8, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
83 ; MIR-NEXT: STRXui %2, %0, 0 :: (store (s64) into %ir.p0, align 4, !alias.scope ![[SET0]], !noalias ![[SET1]])
84 define i32 @test_memset(i32* nocapture %p, i32* nocapture readonly %q) {
85 ; CHECK-LABEL: test_memset:
87 ; CHECK-NEXT: ldp w10, w11, [x1]
88 ; CHECK-NEXT: mov x8, x0
89 ; CHECK-NEXT: mov x9, #-6148914691236517206 // =0xaaaaaaaaaaaaaaaa
90 ; CHECK-NEXT: stp x9, x9, [x8]
91 ; CHECK-NEXT: add w0, w10, w11
93 %p0 = bitcast i32* %p to i8*
94 tail call void @llvm.memset.p0i8.i64(i8* noundef nonnull align 4 dereferenceable(16) %p0, i8 170, i64 16, i1 false), !alias.scope !2, !noalias !4
95 %v0 = load i32, i32* %q, align 4, !alias.scope !4, !noalias !2
96 %q1 = getelementptr inbounds i32, i32* %q, i64 1
97 %v1 = load i32, i32* %q1, align 4, !alias.scope !4, !noalias !2
98 %add = add i32 %v0, %v1
102 ; MIR-LABEL: name: test_mempcpy
103 ; MIR: %2:fpr128 = LDRQui %0, 1 :: (load (s128) from %ir.p1, align 1, !alias.scope ![[SET0]], !noalias ![[SET1]])
104 ; MIR-NEXT: STRQui killed %2, %0, 0 :: (store (s128) into %ir.p0, align 1, !alias.scope ![[SET0]], !noalias ![[SET1]])
105 define i32 @test_mempcpy(i32* nocapture %p, i32* nocapture readonly %q) {
106 ; CHECK-LABEL: test_mempcpy:
108 ; CHECK-NEXT: ldp w9, w10, [x1]
109 ; CHECK-NEXT: ldr q0, [x0, #16]
110 ; CHECK-NEXT: mov x8, x0
111 ; CHECK-NEXT: add w0, w9, w10
112 ; CHECK-NEXT: str q0, [x8]
114 %p0 = bitcast i32* %p to i8*
115 %add.ptr = getelementptr inbounds i32, i32* %p, i64 4
116 %p1 = bitcast i32* %add.ptr to i8*
117 %call = tail call i8* @mempcpy(i8* noundef nonnull align 4 dereferenceable(16) %p0, i8* noundef nonnull align 4 dereferenceable(16) %p1, i64 16), !alias.scope !2, !noalias !4
118 %v0 = load i32, i32* %q, align 4, !alias.scope !4, !noalias !2
119 %q1 = getelementptr inbounds i32, i32* %q, i64 1
120 %v1 = load i32, i32* %q1, align 4, !alias.scope !4, !noalias !2
121 %add = add i32 %v0, %v1
125 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
126 declare void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
127 declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1 immarg)
128 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
130 declare i8* @mempcpy(i8*, i8*, i64)
132 !0 = distinct !{!0, !"bax"}
133 !1 = distinct !{!1, !0, !"bax: %p"}
135 !3 = distinct !{!3, !0, !"bax: %q"}