1 ; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s
2 ; RUN: llc < %s -global-isel -global-isel-abort=1 -pass-remarks-missed=gisel* -mtriple=arm64-linux-gnu 2>&1 | FileCheck %s --check-prefixes=GISEL,FALLBACK
6 define dso_local i128 @f0(ptr %p) nounwind readonly {
8 ; CHECK: ldxp {{x[0-9]+}}, {{x[0-9]+}}, [x0]
10 %ldrexd = tail call %0 @llvm.aarch64.ldxp(ptr %p)
11 %0 = extractvalue %0 %ldrexd, 1
12 %1 = extractvalue %0 %ldrexd, 0
13 %2 = zext i64 %0 to i128
14 %3 = zext i64 %1 to i128
15 %shl = shl nuw i128 %2, 64
20 define dso_local i32 @f1(ptr %ptr, i128 %val) nounwind {
22 ; CHECK: stxp {{w[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, [x0]
24 %tmp4 = trunc i128 %val to i64
25 %tmp6 = lshr i128 %val, 64
26 %tmp7 = trunc i128 %tmp6 to i64
27 %strexd = tail call i32 @llvm.aarch64.stxp(i64 %tmp4, i64 %tmp7, ptr %ptr)
31 declare %0 @llvm.aarch64.ldxp(ptr) nounwind
32 declare i32 @llvm.aarch64.stxp(i64, i64, ptr) nounwind
34 @var = dso_local global i64 0, align 8
36 ; FALLBACK-NOT: remark:{{.*}}test_load_i8
37 define dso_local void @test_load_i8(ptr %addr) {
38 ; CHECK-LABEL: test_load_i8:
39 ; CHECK: ldxrb w[[LOADVAL:[0-9]+]], [x0]
42 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
44 ; GISEL-LABEL: test_load_i8:
45 ; GISEL: ldxrb w[[LOADVAL:[0-9]+]], [x0]
47 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
48 %val = call i64 @llvm.aarch64.ldxr.p0(ptr elementtype(i8) %addr)
49 %shortval = trunc i64 %val to i8
50 %extval = zext i8 %shortval to i64
51 store i64 %extval, ptr @var, align 8
55 ; FALLBACK-NOT: remark:{{.*}}test_load_i16
56 define dso_local void @test_load_i16(ptr %addr) {
57 ; CHECK-LABEL: test_load_i16:
58 ; CHECK: ldxrh w[[LOADVAL:[0-9]+]], [x0]
61 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
63 ; GISEL-LABEL: test_load_i16:
64 ; GISEL: ldxrh w[[LOADVAL:[0-9]+]], [x0]
66 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
67 %val = call i64 @llvm.aarch64.ldxr.p0(ptr elementtype(i16) %addr)
68 %shortval = trunc i64 %val to i16
69 %extval = zext i16 %shortval to i64
70 store i64 %extval, ptr @var, align 8
74 ; FALLBACK-NOT: remark:{{.*}}test_load_i32
75 define dso_local void @test_load_i32(ptr %addr) {
76 ; CHECK-LABEL: test_load_i32:
77 ; CHECK: ldxr w[[LOADVAL:[0-9]+]], [x0]
80 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
82 ; GISEL-LABEL: test_load_i32:
83 ; GISEL: ldxr w[[LOADVAL:[0-9]+]], [x0]
85 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
86 %val = call i64 @llvm.aarch64.ldxr.p0(ptr elementtype(i32) %addr)
87 %shortval = trunc i64 %val to i32
88 %extval = zext i32 %shortval to i64
89 store i64 %extval, ptr @var, align 8
93 ; FALLBACK-NOT: remark:{{.*}}test_load_i64
94 define dso_local void @test_load_i64(ptr %addr) {
95 ; CHECK-LABEL: test_load_i64:
96 ; CHECK: ldxr x[[LOADVAL:[0-9]+]], [x0]
97 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
99 ; GISEL-LABEL: test_load_i64:
100 ; GISEL: ldxr x[[LOADVAL:[0-9]+]], [x0]
102 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
103 %val = call i64 @llvm.aarch64.ldxr.p0(ptr elementtype(i64) %addr)
104 store i64 %val, ptr @var, align 8
109 declare i64 @llvm.aarch64.ldxr.p0(ptr) nounwind
111 ; FALLBACK-NOT: remark:{{.*}}test_store_i8
112 define dso_local i32 @test_store_i8(i32, i8 %val, ptr %addr) {
113 ; CHECK-LABEL: test_store_i8:
116 ; CHECK: stxrb w0, w1, [x2]
117 ; GISEL-LABEL: test_store_i8:
120 ; GISEL: stxrb w0, w1, [x2]
121 %extval = zext i8 %val to i64
122 %res = call i32 @llvm.aarch64.stxr.p0(i64 %extval, ptr elementtype(i8) %addr)
126 ; FALLBACK-NOT: remark:{{.*}}test_store_i16
127 define dso_local i32 @test_store_i16(i32, i16 %val, ptr %addr) {
128 ; CHECK-LABEL: test_store_i16:
131 ; CHECK: stxrh w0, w1, [x2]
132 ; GISEL-LABEL: test_store_i16:
135 ; GISEL: stxrh w0, w1, [x2]
136 %extval = zext i16 %val to i64
137 %res = call i32 @llvm.aarch64.stxr.p0(i64 %extval, ptr elementtype(i16) %addr)
141 ; FALLBACK-NOT: remark:{{.*}}test_store_i32
142 define dso_local i32 @test_store_i32(i32, i32 %val, ptr %addr) {
143 ; CHECK-LABEL: test_store_i32:
146 ; CHECK: stxr w0, w1, [x2]
147 ; GISEL-LABEL: test_store_i32:
150 ; GISEL: stxr w0, w1, [x2]
151 %extval = zext i32 %val to i64
152 %res = call i32 @llvm.aarch64.stxr.p0(i64 %extval, ptr elementtype(i32) %addr)
156 ; FALLBACK-NOT: remark:{{.*}}test_store_i64
157 define dso_local i32 @test_store_i64(i32, i64 %val, ptr %addr) {
158 ; CHECK-LABEL: test_store_i64:
159 ; CHECK: stxr w0, x1, [x2]
160 ; GISEL-LABEL: test_store_i64:
161 ; GISEL: stxr w0, x1, [x2]
162 %res = call i32 @llvm.aarch64.stxr.p0(i64 %val, ptr elementtype(i64) %addr)
166 declare i32 @llvm.aarch64.stxr.p0(i64, ptr) nounwind
170 define dso_local void @test_clear() {
171 call void @llvm.aarch64.clrex()
175 declare void @llvm.aarch64.clrex() nounwind
177 define dso_local i128 @test_load_acquire_i128(ptr %p) nounwind readonly {
178 ; CHECK-LABEL: test_load_acquire_i128:
179 ; CHECK: ldaxp {{x[0-9]+}}, {{x[0-9]+}}, [x0]
181 %ldrexd = tail call %0 @llvm.aarch64.ldaxp(ptr %p)
182 %0 = extractvalue %0 %ldrexd, 1
183 %1 = extractvalue %0 %ldrexd, 0
184 %2 = zext i64 %0 to i128
185 %3 = zext i64 %1 to i128
186 %shl = shl nuw i128 %2, 64
187 %4 = or i128 %shl, %3
191 define dso_local i32 @test_store_release_i128(ptr %ptr, i128 %val) nounwind {
192 ; CHECK-LABEL: test_store_release_i128:
193 ; CHECK: stlxp {{w[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, [x0]
195 %tmp4 = trunc i128 %val to i64
196 %tmp6 = lshr i128 %val, 64
197 %tmp7 = trunc i128 %tmp6 to i64
198 %strexd = tail call i32 @llvm.aarch64.stlxp(i64 %tmp4, i64 %tmp7, ptr %ptr)
202 declare %0 @llvm.aarch64.ldaxp(ptr) nounwind
203 declare i32 @llvm.aarch64.stlxp(i64, i64, ptr) nounwind
205 ; FALLBACK-NOT: remark:{{.*}}test_load_acquire_i8
206 define dso_local void @test_load_acquire_i8(ptr %addr) {
207 ; CHECK-LABEL: test_load_acquire_i8:
208 ; CHECK: ldaxrb w[[LOADVAL:[0-9]+]], [x0]
211 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
213 ; GISEL-LABEL: test_load_acquire_i8:
214 ; GISEL: ldaxrb w[[LOADVAL:[0-9]+]], [x0]
215 ; GISEL-DAG: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
216 %val = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i8) %addr)
217 %shortval = trunc i64 %val to i8
218 %extval = zext i8 %shortval to i64
219 store i64 %extval, ptr @var, align 8
223 ; FALLBACK-NOT: remark:{{.*}}test_load_acquire_i16
224 define dso_local void @test_load_acquire_i16(ptr %addr) {
225 ; CHECK-LABEL: test_load_acquire_i16:
226 ; CHECK: ldaxrh w[[LOADVAL:[0-9]+]], [x0]
229 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
231 ; GISEL-LABEL: test_load_acquire_i16:
232 ; GISEL: ldaxrh w[[LOADVAL:[0-9]+]], [x0]
233 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
234 %val = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i16) %addr)
235 %shortval = trunc i64 %val to i16
236 %extval = zext i16 %shortval to i64
237 store i64 %extval, ptr @var, align 8
241 ; FALLBACK-NOT: remark:{{.*}}test_load_acquire_i32
242 define dso_local void @test_load_acquire_i32(ptr %addr) {
243 ; CHECK-LABEL: test_load_acquire_i32:
244 ; CHECK: ldaxr w[[LOADVAL:[0-9]+]], [x0]
247 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
249 ; GISEL-LABEL: test_load_acquire_i32:
250 ; GISEL: ldaxr w[[LOADVAL:[0-9]+]], [x0]
251 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
252 %val = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i32) %addr)
253 %shortval = trunc i64 %val to i32
254 %extval = zext i32 %shortval to i64
255 store i64 %extval, ptr @var, align 8
259 ; FALLBACK-NOT: remark:{{.*}}test_load_acquire_i64
260 define dso_local void @test_load_acquire_i64(ptr %addr) {
261 ; CHECK-LABEL: test_load_acquire_i64:
262 ; CHECK: ldaxr x[[LOADVAL:[0-9]+]], [x0]
263 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
265 ; GISEL-LABEL: test_load_acquire_i64:
266 ; GISEL: ldaxr x[[LOADVAL:[0-9]+]], [x0]
267 ; GISEL: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
268 %val = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i64) %addr)
269 store i64 %val, ptr @var, align 8
274 declare i64 @llvm.aarch64.ldaxr.p0(ptr) nounwind
276 ; FALLBACK-NOT: remark:{{.*}}test_store_release_i8
277 define dso_local i32 @test_store_release_i8(i32, i8 %val, ptr %addr) {
278 ; CHECK-LABEL: test_store_release_i8:
281 ; CHECK: stlxrb w0, w1, [x2]
282 ; GISEL-LABEL: test_store_release_i8:
285 ; GISEL: stlxrb w0, w1, [x2]
286 %extval = zext i8 %val to i64
287 %res = call i32 @llvm.aarch64.stlxr.p0(i64 %extval, ptr elementtype(i8) %addr)
291 ; FALLBACK-NOT: remark:{{.*}}test_store_release_i16
292 define dso_local i32 @test_store_release_i16(i32, i16 %val, ptr %addr) {
293 ; CHECK-LABEL: test_store_release_i16:
296 ; CHECK: stlxrh w0, w1, [x2]
297 ; GISEL-LABEL: test_store_release_i16:
300 ; GISEL: stlxrh w0, w1, [x2]
301 %extval = zext i16 %val to i64
302 %res = call i32 @llvm.aarch64.stlxr.p0(i64 %extval, ptr elementtype(i16) %addr)
306 ; FALLBACK-NOT: remark:{{.*}}test_store_release_i32
307 define dso_local i32 @test_store_release_i32(i32, i32 %val, ptr %addr) {
308 ; CHECK-LABEL: test_store_release_i32:
311 ; CHECK: stlxr w0, w1, [x2]
312 ; GISEL-LABEL: test_store_release_i32:
315 ; GISEL: stlxr w0, w1, [x2]
316 %extval = zext i32 %val to i64
317 %res = call i32 @llvm.aarch64.stlxr.p0(i64 %extval, ptr elementtype(i32) %addr)
321 ; FALLBACK-NOT: remark:{{.*}}test_store_release_i64
322 define dso_local i32 @test_store_release_i64(i32, i64 %val, ptr %addr) {
323 ; CHECK-LABEL: test_store_release_i64:
324 ; CHECK: stlxr w0, x1, [x2]
325 ; GISEL-LABEL: test_store_release_i64:
326 ; GISEL: stlxr w0, x1, [x2]
327 %res = call i32 @llvm.aarch64.stlxr.p0(i64 %val, ptr elementtype(i64) %addr)
331 declare i32 @llvm.aarch64.stlxr.p0(i64, ptr) nounwind