1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -mtriple=aarch64-linux-gnu -atomic-expand %s | FileCheck %s
3
4define float @test_atomicrmw_fadd_f32(float* %ptr, float %value) {
5; CHECK-LABEL: @test_atomicrmw_fadd_f32(
6; CHECK-NEXT:    [[TMP1:%.*]] = load float, float* [[PTR:%.*]], align 4
7; CHECK-NEXT:    br label [[ATOMICRMW_START:%.*]]
8; CHECK:       atomicrmw.start:
9; CHECK-NEXT:    [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
10; CHECK-NEXT:    [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
11; CHECK-NEXT:    [[TMP2:%.*]] = bitcast float* [[PTR]] to i32*
12; CHECK-NEXT:    [[TMP3:%.*]] = bitcast float [[NEW]] to i32
13; CHECK-NEXT:    [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
14; CHECK-NEXT:    [[TMP5:%.*]] = cmpxchg i32* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
15; CHECK-NEXT:    [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
16; CHECK-NEXT:    [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
17; CHECK-NEXT:    [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
18; CHECK-NEXT:    br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
19; CHECK:       atomicrmw.end:
20; CHECK-NEXT:    ret float [[TMP6]]
21;
22  %res = atomicrmw fadd float* %ptr, float %value seq_cst
23  ret float %res
24}
25
26define float @test_atomicrmw_fsub_f32(float* %ptr, float %value) {
27; CHECK-LABEL: @test_atomicrmw_fsub_f32(
28; CHECK-NEXT:    [[TMP1:%.*]] = load float, float* [[PTR:%.*]], align 4
29; CHECK-NEXT:    br label [[ATOMICRMW_START:%.*]]
30; CHECK:       atomicrmw.start:
31; CHECK-NEXT:    [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
32; CHECK-NEXT:    [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
33; CHECK-NEXT:    [[TMP2:%.*]] = bitcast float* [[PTR]] to i32*
34; CHECK-NEXT:    [[TMP3:%.*]] = bitcast float [[NEW]] to i32
35; CHECK-NEXT:    [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
36; CHECK-NEXT:    [[TMP5:%.*]] = cmpxchg i32* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
37; CHECK-NEXT:    [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
38; CHECK-NEXT:    [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
39; CHECK-NEXT:    [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
40; CHECK-NEXT:    br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
41; CHECK:       atomicrmw.end:
42; CHECK-NEXT:    ret float [[TMP6]]
43;
44  %res = atomicrmw fsub float* %ptr, float %value seq_cst
45  ret float %res
46}
47
48