1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=aarch64-- -atomic-expand %s | FileCheck %s
4 define void @atomic_swap_f16(half* %ptr, half %val) nounwind {
5 ; CHECK-LABEL: @atomic_swap_f16(
6 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
7 ; CHECK: atomicrmw.start:
8 ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.aarch64.ldaxr.p0f16(half* [[PTR:%.*]])
9 ; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP1]] to i16
10 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i16 [[TMP2]] to half
11 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast half [[VAL:%.*]] to i16
12 ; CHECK-NEXT: [[TMP5:%.*]] = zext i16 [[TMP4]] to i64
13 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @llvm.aarch64.stxr.p0f16(i64 [[TMP5]], half* [[PTR]])
14 ; CHECK-NEXT: [[TRYAGAIN:%.*]] = icmp ne i32 [[TMP6]], 0
15 ; CHECK-NEXT: br i1 [[TRYAGAIN]], label [[ATOMICRMW_START]], label [[ATOMICRMW_END:%.*]]
16 ; CHECK: atomicrmw.end:
17 ; CHECK-NEXT: ret void
19 %t1 = atomicrmw xchg half* %ptr, half %val acquire
23 define void @atomic_swap_f32(float* %ptr, float %val) nounwind {
24 ; CHECK-LABEL: @atomic_swap_f32(
25 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
26 ; CHECK: atomicrmw.start:
27 ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.aarch64.ldaxr.p0f32(float* [[PTR:%.*]])
28 ; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP1]] to i32
29 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32 [[TMP2]] to float
30 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast float [[VAL:%.*]] to i32
31 ; CHECK-NEXT: [[TMP5:%.*]] = zext i32 [[TMP4]] to i64
32 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @llvm.aarch64.stxr.p0f32(i64 [[TMP5]], float* [[PTR]])
33 ; CHECK-NEXT: [[TRYAGAIN:%.*]] = icmp ne i32 [[TMP6]], 0
34 ; CHECK-NEXT: br i1 [[TRYAGAIN]], label [[ATOMICRMW_START]], label [[ATOMICRMW_END:%.*]]
35 ; CHECK: atomicrmw.end:
36 ; CHECK-NEXT: ret void
38 %t1 = atomicrmw xchg float* %ptr, float %val acquire
42 define void @atomic_swap_f64(double* %ptr, double %val) nounwind {
43 ; CHECK-LABEL: @atomic_swap_f64(
44 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
45 ; CHECK: atomicrmw.start:
46 ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.aarch64.ldaxr.p0f64(double* [[PTR:%.*]])
47 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i64 [[TMP1]] to double
48 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast double [[VAL:%.*]] to i64
49 ; CHECK-NEXT: [[TMP4:%.*]] = call i32 @llvm.aarch64.stxr.p0f64(i64 [[TMP3]], double* [[PTR]])
50 ; CHECK-NEXT: [[TRYAGAIN:%.*]] = icmp ne i32 [[TMP4]], 0
51 ; CHECK-NEXT: br i1 [[TRYAGAIN]], label [[ATOMICRMW_START]], label [[ATOMICRMW_END:%.*]]
52 ; CHECK: atomicrmw.end:
53 ; CHECK-NEXT: ret void
55 %t1 = atomicrmw xchg double* %ptr, double %val acquire