1 ; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s
5 define i128 @f0(i8* %p) nounwind readonly {
7 ; CHECK: ldxp {{x[0-9]+}}, {{x[0-9]+}}, [x0]
9 %ldrexd = tail call %0 @llvm.aarch64.ldxp(i8* %p)
10 %0 = extractvalue %0 %ldrexd, 1
11 %1 = extractvalue %0 %ldrexd, 0
12 %2 = zext i64 %0 to i128
13 %3 = zext i64 %1 to i128
14 %shl = shl nuw i128 %2, 64
19 define i32 @f1(i8* %ptr, i128 %val) nounwind {
21 ; CHECK: stxp {{w[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, [x0]
23 %tmp4 = trunc i128 %val to i64
24 %tmp6 = lshr i128 %val, 64
25 %tmp7 = trunc i128 %tmp6 to i64
26 %strexd = tail call i32 @llvm.aarch64.stxp(i64 %tmp4, i64 %tmp7, i8* %ptr)
30 declare %0 @llvm.aarch64.ldxp(i8*) nounwind
31 declare i32 @llvm.aarch64.stxp(i64, i64, i8*) nounwind
33 @var = global i64 0, align 8
35 define void @test_load_i8(i8* %addr) {
36 ; CHECK-LABEL: test_load_i8:
37 ; CHECK: ldxrb w[[LOADVAL:[0-9]+]], [x0]
40 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
42 %val = call i64 @llvm.aarch64.ldxr.p0i8(i8* %addr)
43 %shortval = trunc i64 %val to i8
44 %extval = zext i8 %shortval to i64
45 store i64 %extval, i64* @var, align 8
49 define void @test_load_i16(i16* %addr) {
50 ; CHECK-LABEL: test_load_i16:
51 ; CHECK: ldxrh w[[LOADVAL:[0-9]+]], [x0]
54 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
56 %val = call i64 @llvm.aarch64.ldxr.p0i16(i16* %addr)
57 %shortval = trunc i64 %val to i16
58 %extval = zext i16 %shortval to i64
59 store i64 %extval, i64* @var, align 8
63 define void @test_load_i32(i32* %addr) {
64 ; CHECK-LABEL: test_load_i32:
65 ; CHECK: ldxr w[[LOADVAL:[0-9]+]], [x0]
68 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
70 %val = call i64 @llvm.aarch64.ldxr.p0i32(i32* %addr)
71 %shortval = trunc i64 %val to i32
72 %extval = zext i32 %shortval to i64
73 store i64 %extval, i64* @var, align 8
77 define void @test_load_i64(i64* %addr) {
78 ; CHECK-LABEL: test_load_i64:
79 ; CHECK: ldxr x[[LOADVAL:[0-9]+]], [x0]
80 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
82 %val = call i64 @llvm.aarch64.ldxr.p0i64(i64* %addr)
83 store i64 %val, i64* @var, align 8
88 declare i64 @llvm.aarch64.ldxr.p0i8(i8*) nounwind
89 declare i64 @llvm.aarch64.ldxr.p0i16(i16*) nounwind
90 declare i64 @llvm.aarch64.ldxr.p0i32(i32*) nounwind
91 declare i64 @llvm.aarch64.ldxr.p0i64(i64*) nounwind
93 define i32 @test_store_i8(i32, i8 %val, i8* %addr) {
94 ; CHECK-LABEL: test_store_i8:
97 ; CHECK: stxrb w0, w1, [x2]
98 %extval = zext i8 %val to i64
99 %res = call i32 @llvm.aarch64.stxr.p0i8(i64 %extval, i8* %addr)
103 define i32 @test_store_i16(i32, i16 %val, i16* %addr) {
104 ; CHECK-LABEL: test_store_i16:
107 ; CHECK: stxrh w0, w1, [x2]
108 %extval = zext i16 %val to i64
109 %res = call i32 @llvm.aarch64.stxr.p0i16(i64 %extval, i16* %addr)
113 define i32 @test_store_i32(i32, i32 %val, i32* %addr) {
114 ; CHECK-LABEL: test_store_i32:
117 ; CHECK: stxr w0, w1, [x2]
118 %extval = zext i32 %val to i64
119 %res = call i32 @llvm.aarch64.stxr.p0i32(i64 %extval, i32* %addr)
123 define i32 @test_store_i64(i32, i64 %val, i64* %addr) {
124 ; CHECK-LABEL: test_store_i64:
125 ; CHECK: stxr w0, x1, [x2]
126 %res = call i32 @llvm.aarch64.stxr.p0i64(i64 %val, i64* %addr)
130 declare i32 @llvm.aarch64.stxr.p0i8(i64, i8*) nounwind
131 declare i32 @llvm.aarch64.stxr.p0i16(i64, i16*) nounwind
132 declare i32 @llvm.aarch64.stxr.p0i32(i64, i32*) nounwind
133 declare i32 @llvm.aarch64.stxr.p0i64(i64, i64*) nounwind
137 define void @test_clear() {
138 call void @llvm.aarch64.clrex()
142 declare void @llvm.aarch64.clrex() nounwind
144 define i128 @test_load_acquire_i128(i8* %p) nounwind readonly {
145 ; CHECK-LABEL: test_load_acquire_i128:
146 ; CHECK: ldaxp {{x[0-9]+}}, {{x[0-9]+}}, [x0]
148 %ldrexd = tail call %0 @llvm.aarch64.ldaxp(i8* %p)
149 %0 = extractvalue %0 %ldrexd, 1
150 %1 = extractvalue %0 %ldrexd, 0
151 %2 = zext i64 %0 to i128
152 %3 = zext i64 %1 to i128
153 %shl = shl nuw i128 %2, 64
154 %4 = or i128 %shl, %3
158 define i32 @test_store_release_i128(i8* %ptr, i128 %val) nounwind {
159 ; CHECK-LABEL: test_store_release_i128:
160 ; CHECK: stlxp {{w[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, [x0]
162 %tmp4 = trunc i128 %val to i64
163 %tmp6 = lshr i128 %val, 64
164 %tmp7 = trunc i128 %tmp6 to i64
165 %strexd = tail call i32 @llvm.aarch64.stlxp(i64 %tmp4, i64 %tmp7, i8* %ptr)
169 declare %0 @llvm.aarch64.ldaxp(i8*) nounwind
170 declare i32 @llvm.aarch64.stlxp(i64, i64, i8*) nounwind
172 define void @test_load_acquire_i8(i8* %addr) {
173 ; CHECK-LABEL: test_load_acquire_i8:
174 ; CHECK: ldaxrb w[[LOADVAL:[0-9]+]], [x0]
177 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
179 %val = call i64 @llvm.aarch64.ldaxr.p0i8(i8* %addr)
180 %shortval = trunc i64 %val to i8
181 %extval = zext i8 %shortval to i64
182 store i64 %extval, i64* @var, align 8
186 define void @test_load_acquire_i16(i16* %addr) {
187 ; CHECK-LABEL: test_load_acquire_i16:
188 ; CHECK: ldaxrh w[[LOADVAL:[0-9]+]], [x0]
191 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
193 %val = call i64 @llvm.aarch64.ldaxr.p0i16(i16* %addr)
194 %shortval = trunc i64 %val to i16
195 %extval = zext i16 %shortval to i64
196 store i64 %extval, i64* @var, align 8
200 define void @test_load_acquire_i32(i32* %addr) {
201 ; CHECK-LABEL: test_load_acquire_i32:
202 ; CHECK: ldaxr w[[LOADVAL:[0-9]+]], [x0]
205 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
207 %val = call i64 @llvm.aarch64.ldaxr.p0i32(i32* %addr)
208 %shortval = trunc i64 %val to i32
209 %extval = zext i32 %shortval to i64
210 store i64 %extval, i64* @var, align 8
214 define void @test_load_acquire_i64(i64* %addr) {
215 ; CHECK-LABEL: test_load_acquire_i64:
216 ; CHECK: ldaxr x[[LOADVAL:[0-9]+]], [x0]
217 ; CHECK: str x[[LOADVAL]], [{{x[0-9]+}}, :lo12:var]
219 %val = call i64 @llvm.aarch64.ldaxr.p0i64(i64* %addr)
220 store i64 %val, i64* @var, align 8
225 declare i64 @llvm.aarch64.ldaxr.p0i8(i8*) nounwind
226 declare i64 @llvm.aarch64.ldaxr.p0i16(i16*) nounwind
227 declare i64 @llvm.aarch64.ldaxr.p0i32(i32*) nounwind
228 declare i64 @llvm.aarch64.ldaxr.p0i64(i64*) nounwind
230 define i32 @test_store_release_i8(i32, i8 %val, i8* %addr) {
231 ; CHECK-LABEL: test_store_release_i8:
234 ; CHECK: stlxrb w0, w1, [x2]
235 %extval = zext i8 %val to i64
236 %res = call i32 @llvm.aarch64.stlxr.p0i8(i64 %extval, i8* %addr)
240 define i32 @test_store_release_i16(i32, i16 %val, i16* %addr) {
241 ; CHECK-LABEL: test_store_release_i16:
244 ; CHECK: stlxrh w0, w1, [x2]
245 %extval = zext i16 %val to i64
246 %res = call i32 @llvm.aarch64.stlxr.p0i16(i64 %extval, i16* %addr)
250 define i32 @test_store_release_i32(i32, i32 %val, i32* %addr) {
251 ; CHECK-LABEL: test_store_release_i32:
254 ; CHECK: stlxr w0, w1, [x2]
255 %extval = zext i32 %val to i64
256 %res = call i32 @llvm.aarch64.stlxr.p0i32(i64 %extval, i32* %addr)
260 define i32 @test_store_release_i64(i32, i64 %val, i64* %addr) {
261 ; CHECK-LABEL: test_store_release_i64:
262 ; CHECK: stlxr w0, x1, [x2]
263 %res = call i32 @llvm.aarch64.stlxr.p0i64(i64 %val, i64* %addr)
267 declare i32 @llvm.aarch64.stlxr.p0i8(i64, i8*) nounwind
268 declare i32 @llvm.aarch64.stlxr.p0i16(i64, i16*) nounwind
269 declare i32 @llvm.aarch64.stlxr.p0i32(i64, i32*) nounwind
270 declare i32 @llvm.aarch64.stlxr.p0i64(i64, i64*) nounwind