1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -codegen-opt-level=1 -S -mtriple=aarch64-- -passes=atomic-expand %s | FileCheck %s
3 ; RUN: opt -codegen-opt-level=1 -S -mtriple=aarch64-- -mattr=+outline-atomics -passes=atomic-expand %s | FileCheck %s --check-prefix=OUTLINE-ATOMICS
5 define void @atomic_swap_f16(ptr %ptr, half %val) nounwind {
6 ; CHECK-LABEL: @atomic_swap_f16(
7 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast half [[VAL:%.*]] to i16
8 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
9 ; CHECK: atomicrmw.start:
10 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i16) [[PTR:%.*]])
11 ; CHECK-NEXT: [[TMP3:%.*]] = trunc i64 [[TMP2]] to i16
12 ; CHECK-NEXT: [[TMP4:%.*]] = zext i16 [[TMP1]] to i64
13 ; CHECK-NEXT: [[TMP5:%.*]] = call i32 @llvm.aarch64.stxr.p0(i64 [[TMP4]], ptr elementtype(i16) [[PTR]])
14 ; CHECK-NEXT: [[TRYAGAIN:%.*]] = icmp ne i32 [[TMP5]], 0
15 ; CHECK-NEXT: br i1 [[TRYAGAIN]], label [[ATOMICRMW_START]], label [[ATOMICRMW_END:%.*]]
16 ; CHECK: atomicrmw.end:
17 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast i16 [[TMP3]] to half
18 ; CHECK-NEXT: ret void
20 ; OUTLINE-ATOMICS-LABEL: @atomic_swap_f16(
21 ; OUTLINE-ATOMICS-NEXT: [[TMP1:%.*]] = bitcast half [[VAL:%.*]] to i16
22 ; OUTLINE-ATOMICS-NEXT: [[TMP2:%.*]] = atomicrmw xchg ptr [[PTR:%.*]], i16 [[TMP1]] acquire, align 2
23 ; OUTLINE-ATOMICS-NEXT: [[TMP3:%.*]] = bitcast i16 [[TMP2]] to half
24 ; OUTLINE-ATOMICS-NEXT: ret void
26 %t1 = atomicrmw xchg ptr %ptr, half %val acquire
30 define void @atomic_swap_f32(ptr %ptr, float %val) nounwind {
31 ; CHECK-LABEL: @atomic_swap_f32(
32 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast float [[VAL:%.*]] to i32
33 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
34 ; CHECK: atomicrmw.start:
35 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i32) [[PTR:%.*]])
36 ; CHECK-NEXT: [[TMP3:%.*]] = trunc i64 [[TMP2]] to i32
37 ; CHECK-NEXT: [[TMP4:%.*]] = zext i32 [[TMP1]] to i64
38 ; CHECK-NEXT: [[TMP5:%.*]] = call i32 @llvm.aarch64.stxr.p0(i64 [[TMP4]], ptr elementtype(i32) [[PTR]])
39 ; CHECK-NEXT: [[TRYAGAIN:%.*]] = icmp ne i32 [[TMP5]], 0
40 ; CHECK-NEXT: br i1 [[TRYAGAIN]], label [[ATOMICRMW_START]], label [[ATOMICRMW_END:%.*]]
41 ; CHECK: atomicrmw.end:
42 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast i32 [[TMP3]] to float
43 ; CHECK-NEXT: ret void
45 ; OUTLINE-ATOMICS-LABEL: @atomic_swap_f32(
46 ; OUTLINE-ATOMICS-NEXT: [[TMP1:%.*]] = bitcast float [[VAL:%.*]] to i32
47 ; OUTLINE-ATOMICS-NEXT: [[TMP2:%.*]] = atomicrmw xchg ptr [[PTR:%.*]], i32 [[TMP1]] acquire, align 4
48 ; OUTLINE-ATOMICS-NEXT: [[TMP3:%.*]] = bitcast i32 [[TMP2]] to float
49 ; OUTLINE-ATOMICS-NEXT: ret void
51 %t1 = atomicrmw xchg ptr %ptr, float %val acquire
55 define void @atomic_swap_f64(ptr %ptr, double %val) nounwind {
56 ; CHECK-LABEL: @atomic_swap_f64(
57 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast double [[VAL:%.*]] to i64
58 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
59 ; CHECK: atomicrmw.start:
60 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.aarch64.ldaxr.p0(ptr elementtype(i64) [[PTR:%.*]])
61 ; CHECK-NEXT: [[TMP3:%.*]] = call i32 @llvm.aarch64.stxr.p0(i64 [[TMP1]], ptr elementtype(i64) [[PTR]])
62 ; CHECK-NEXT: [[TRYAGAIN:%.*]] = icmp ne i32 [[TMP3]], 0
63 ; CHECK-NEXT: br i1 [[TRYAGAIN]], label [[ATOMICRMW_START]], label [[ATOMICRMW_END:%.*]]
64 ; CHECK: atomicrmw.end:
65 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast i64 [[TMP2]] to double
66 ; CHECK-NEXT: ret void
68 ; OUTLINE-ATOMICS-LABEL: @atomic_swap_f64(
69 ; OUTLINE-ATOMICS-NEXT: [[TMP1:%.*]] = bitcast double [[VAL:%.*]] to i64
70 ; OUTLINE-ATOMICS-NEXT: [[TMP2:%.*]] = atomicrmw xchg ptr [[PTR:%.*]], i64 [[TMP1]] acquire, align 8
71 ; OUTLINE-ATOMICS-NEXT: [[TMP3:%.*]] = bitcast i64 [[TMP2]] to double
72 ; OUTLINE-ATOMICS-NEXT: ret void
74 %t1 = atomicrmw xchg ptr %ptr, double %val acquire