1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -atomic-expand %s | FileCheck -check-prefix=GCN %s
3 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -atomic-expand %s | FileCheck -check-prefix=GCN %s
5 define float @test_atomicrmw_fadd_f32_flat(float* %ptr, float %value) {
6 ; GCN-LABEL: @test_atomicrmw_fadd_f32_flat(
7 ; GCN-NEXT: [[TMP1:%.*]] = load float, float* [[PTR:%.*]], align 4
8 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
9 ; GCN: atomicrmw.start:
10 ; GCN-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
11 ; GCN-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
12 ; GCN-NEXT: [[TMP2:%.*]] = bitcast float* [[PTR]] to i32*
13 ; GCN-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
14 ; GCN-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
15 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i32* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
16 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
17 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
18 ; GCN-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
19 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
21 ; GCN-NEXT: ret float [[TMP6]]
23 %res = atomicrmw fsub float* %ptr, float %value seq_cst
27 define float @test_atomicrmw_fsub_f32_global(float addrspace(1)* %ptr, float %value) {
28 ; GCN-LABEL: @test_atomicrmw_fsub_f32_global(
29 ; GCN-NEXT: [[TMP1:%.*]] = load float, float addrspace(1)* [[PTR:%.*]], align 4
30 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
31 ; GCN: atomicrmw.start:
32 ; GCN-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
33 ; GCN-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
34 ; GCN-NEXT: [[TMP2:%.*]] = bitcast float addrspace(1)* [[PTR]] to i32 addrspace(1)*
35 ; GCN-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
36 ; GCN-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
37 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(1)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
38 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
39 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
40 ; GCN-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
41 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
43 ; GCN-NEXT: ret float [[TMP6]]
45 %res = atomicrmw fsub float addrspace(1)* %ptr, float %value seq_cst
49 define float @test_atomicrmw_fsub_f32_local(float addrspace(3)* %ptr, float %value) {
50 ; GCN-LABEL: @test_atomicrmw_fsub_f32_local(
51 ; GCN-NEXT: [[TMP1:%.*]] = load float, float addrspace(3)* [[PTR:%.*]], align 4
52 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
53 ; GCN: atomicrmw.start:
54 ; GCN-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
55 ; GCN-NEXT: [[NEW:%.*]] = fsub float [[LOADED]], [[VALUE:%.*]]
56 ; GCN-NEXT: [[TMP2:%.*]] = bitcast float addrspace(3)* [[PTR]] to i32 addrspace(3)*
57 ; GCN-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
58 ; GCN-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
59 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(3)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
60 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
61 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
62 ; GCN-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
63 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
65 ; GCN-NEXT: ret float [[TMP6]]
67 %res = atomicrmw fsub float addrspace(3)* %ptr, float %value seq_cst
71 define half @test_atomicrmw_fsub_f16_flat(half* %ptr, half %value) {
72 ; GCN-LABEL: @test_atomicrmw_fsub_f16_flat(
73 ; GCN-NEXT: [[TMP1:%.*]] = load half, half* [[PTR:%.*]], align 2
74 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
75 ; GCN: atomicrmw.start:
76 ; GCN-NEXT: [[LOADED:%.*]] = phi half [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
77 ; GCN-NEXT: [[NEW:%.*]] = fsub half [[LOADED]], [[VALUE:%.*]]
78 ; GCN-NEXT: [[TMP2:%.*]] = bitcast half* [[PTR]] to i16*
79 ; GCN-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
80 ; GCN-NEXT: [[TMP4:%.*]] = bitcast half [[LOADED]] to i16
81 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i16* [[TMP2]], i16 [[TMP4]], i16 [[TMP3]] seq_cst seq_cst
82 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i16, i1 } [[TMP5]], 1
83 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i16, i1 } [[TMP5]], 0
84 ; GCN-NEXT: [[TMP6]] = bitcast i16 [[NEWLOADED]] to half
85 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
87 ; GCN-NEXT: ret half [[TMP6]]
89 %res = atomicrmw fsub half* %ptr, half %value seq_cst
93 define half @test_atomicrmw_fsub_f16_global(half addrspace(1)* %ptr, half %value) {
94 ; GCN-LABEL: @test_atomicrmw_fsub_f16_global(
95 ; GCN-NEXT: [[TMP1:%.*]] = load half, half addrspace(1)* [[PTR:%.*]], align 2
96 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
97 ; GCN: atomicrmw.start:
98 ; GCN-NEXT: [[LOADED:%.*]] = phi half [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
99 ; GCN-NEXT: [[NEW:%.*]] = fsub half [[LOADED]], [[VALUE:%.*]]
100 ; GCN-NEXT: [[TMP2:%.*]] = bitcast half addrspace(1)* [[PTR]] to i16 addrspace(1)*
101 ; GCN-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
102 ; GCN-NEXT: [[TMP4:%.*]] = bitcast half [[LOADED]] to i16
103 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i16 addrspace(1)* [[TMP2]], i16 [[TMP4]], i16 [[TMP3]] seq_cst seq_cst
104 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i16, i1 } [[TMP5]], 1
105 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i16, i1 } [[TMP5]], 0
106 ; GCN-NEXT: [[TMP6]] = bitcast i16 [[NEWLOADED]] to half
107 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
108 ; GCN: atomicrmw.end:
109 ; GCN-NEXT: ret half [[TMP6]]
111 %res = atomicrmw fsub half addrspace(1)* %ptr, half %value seq_cst
115 define half @test_atomicrmw_fsub_f16_local(half addrspace(3)* %ptr, half %value) {
116 ; GCN-LABEL: @test_atomicrmw_fsub_f16_local(
117 ; GCN-NEXT: [[TMP1:%.*]] = load half, half addrspace(3)* [[PTR:%.*]], align 2
118 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
119 ; GCN: atomicrmw.start:
120 ; GCN-NEXT: [[LOADED:%.*]] = phi half [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
121 ; GCN-NEXT: [[NEW:%.*]] = fsub half [[LOADED]], [[VALUE:%.*]]
122 ; GCN-NEXT: [[TMP2:%.*]] = bitcast half addrspace(3)* [[PTR]] to i16 addrspace(3)*
123 ; GCN-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
124 ; GCN-NEXT: [[TMP4:%.*]] = bitcast half [[LOADED]] to i16
125 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i16 addrspace(3)* [[TMP2]], i16 [[TMP4]], i16 [[TMP3]] seq_cst seq_cst
126 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i16, i1 } [[TMP5]], 1
127 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i16, i1 } [[TMP5]], 0
128 ; GCN-NEXT: [[TMP6]] = bitcast i16 [[NEWLOADED]] to half
129 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
130 ; GCN: atomicrmw.end:
131 ; GCN-NEXT: ret half [[TMP6]]
133 %res = atomicrmw fsub half addrspace(3)* %ptr, half %value seq_cst
137 define double @test_atomicrmw_fsub_f64_flat(double* %ptr, double %value) {
138 ; GCN-LABEL: @test_atomicrmw_fsub_f64_flat(
139 ; GCN-NEXT: [[TMP1:%.*]] = load double, double* [[PTR:%.*]], align 8
140 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
141 ; GCN: atomicrmw.start:
142 ; GCN-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
143 ; GCN-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
144 ; GCN-NEXT: [[TMP2:%.*]] = bitcast double* [[PTR]] to i64*
145 ; GCN-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
146 ; GCN-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
147 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i64* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
148 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
149 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
150 ; GCN-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
151 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
152 ; GCN: atomicrmw.end:
153 ; GCN-NEXT: ret double [[TMP6]]
155 %res = atomicrmw fsub double* %ptr, double %value seq_cst
159 define double @test_atomicrmw_fsub_f64_global(double addrspace(1)* %ptr, double %value) {
160 ; GCN-LABEL: @test_atomicrmw_fsub_f64_global(
161 ; GCN-NEXT: [[TMP1:%.*]] = load double, double addrspace(1)* [[PTR:%.*]], align 8
162 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
163 ; GCN: atomicrmw.start:
164 ; GCN-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
165 ; GCN-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
166 ; GCN-NEXT: [[TMP2:%.*]] = bitcast double addrspace(1)* [[PTR]] to i64 addrspace(1)*
167 ; GCN-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
168 ; GCN-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
169 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i64 addrspace(1)* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
170 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
171 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
172 ; GCN-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
173 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
174 ; GCN: atomicrmw.end:
175 ; GCN-NEXT: ret double [[TMP6]]
177 %res = atomicrmw fsub double addrspace(1)* %ptr, double %value seq_cst
181 define double @test_atomicrmw_fsub_f64_local(double addrspace(3)* %ptr, double %value) {
182 ; GCN-LABEL: @test_atomicrmw_fsub_f64_local(
183 ; GCN-NEXT: [[TMP1:%.*]] = load double, double addrspace(3)* [[PTR:%.*]], align 8
184 ; GCN-NEXT: br label [[ATOMICRMW_START:%.*]]
185 ; GCN: atomicrmw.start:
186 ; GCN-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
187 ; GCN-NEXT: [[NEW:%.*]] = fsub double [[LOADED]], [[VALUE:%.*]]
188 ; GCN-NEXT: [[TMP2:%.*]] = bitcast double addrspace(3)* [[PTR]] to i64 addrspace(3)*
189 ; GCN-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
190 ; GCN-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
191 ; GCN-NEXT: [[TMP5:%.*]] = cmpxchg i64 addrspace(3)* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
192 ; GCN-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
193 ; GCN-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
194 ; GCN-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
195 ; GCN-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
196 ; GCN: atomicrmw.end:
197 ; GCN-NEXT: ret double [[TMP6]]
199 %res = atomicrmw fsub double addrspace(3)* %ptr, double %value seq_cst