1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=i686-linux-gnu -atomic-expand %s | FileCheck %s
4 define float @test_atomicrmw_fadd_f32(ptr %ptr, float %value) {
5 ; CHECK-LABEL: @test_atomicrmw_fadd_f32(
6 ; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr [[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: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
12 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
13 ; CHECK-NEXT: [[TMP5:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
14 ; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
15 ; CHECK-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
16 ; CHECK-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
17 ; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
18 ; CHECK: atomicrmw.end:
19 ; CHECK-NEXT: ret float [[TMP6]]
21 %res = atomicrmw fadd ptr %ptr, float %value seq_cst
25 define double @test_atomicrmw_fadd_f64(ptr %ptr, double %value) {
26 ; CHECK-LABEL: @test_atomicrmw_fadd_f64(
27 ; CHECK-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
28 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
29 ; CHECK: atomicrmw.start:
30 ; CHECK-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
31 ; CHECK-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
32 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
33 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
34 ; CHECK-NEXT: [[TMP5:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
35 ; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
36 ; CHECK-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
37 ; CHECK-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
38 ; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
39 ; CHECK: atomicrmw.end:
40 ; CHECK-NEXT: ret double [[TMP6]]
42 %res = atomicrmw fadd ptr %ptr, double %value seq_cst
46 define float @test_atomicrmw_fadd_f32_as1(ptr addrspace(1) %ptr, float %value) {
47 ; CHECK-LABEL: @test_atomicrmw_fadd_f32_as1(
48 ; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
49 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
50 ; CHECK: atomicrmw.start:
51 ; CHECK-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
52 ; CHECK-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
53 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
54 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
55 ; CHECK-NEXT: [[TMP5:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
56 ; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
57 ; CHECK-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
58 ; CHECK-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
59 ; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
60 ; CHECK: atomicrmw.end:
61 ; CHECK-NEXT: ret float [[TMP6]]
63 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value seq_cst
67 define float @test_atomicrmw_fsub_f32(ptr %ptr, float %value) {
68 ; CHECK-LABEL: @test_atomicrmw_fsub_f32(
69 ; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
70 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
71 ; CHECK: atomicrmw.start:
72 ; CHECK-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
73 ; CHECK-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
74 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
75 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
76 ; CHECK-NEXT: [[TMP5:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
77 ; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
78 ; CHECK-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
79 ; CHECK-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
80 ; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
81 ; CHECK: atomicrmw.end:
82 ; CHECK-NEXT: ret float [[TMP6]]
84 %res = atomicrmw fsub ptr %ptr, float %value seq_cst
88 define double @test_atomicrmw_fsub_f64(ptr %ptr, double %value) {
89 ; CHECK-LABEL: @test_atomicrmw_fsub_f64(
90 ; CHECK-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
91 ; CHECK-NEXT: br label [[ATOMICRMW_START:%.*]]
92 ; CHECK: atomicrmw.start:
93 ; CHECK-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
94 ; CHECK-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
95 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
96 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
97 ; CHECK-NEXT: [[TMP5:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
98 ; CHECK-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
99 ; CHECK-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
100 ; CHECK-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
101 ; CHECK-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
102 ; CHECK: atomicrmw.end:
103 ; CHECK-NEXT: ret double [[TMP6]]
105 %res = atomicrmw fsub ptr %ptr, double %value seq_cst