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=CI %s
3 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -atomic-expand %s | FileCheck -check-prefix=GFX9 %s
4 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -atomic-expand %s | FileCheck -check-prefix=GFX908 %s
5 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -atomic-expand %s | FileCheck -check-prefix=GFX90A %s
6 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -atomic-expand %s | FileCheck -check-prefix=GFX940 %s
7 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -atomic-expand %s | FileCheck -check-prefix=GFX11 %s
9 define void @test_atomicrmw_fadd_f32_global_no_use_unsafe(ptr addrspace(1) %ptr, float %value) #0 {
10 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe(
11 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
12 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
13 ; CI: atomicrmw.start:
14 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
15 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
16 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
17 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
18 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
19 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
20 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
21 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
22 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
26 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe(
27 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
28 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
29 ; GFX9: atomicrmw.start:
30 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
31 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
32 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
33 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
34 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
35 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
36 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
37 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
38 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
39 ; GFX9: atomicrmw.end:
42 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe(
43 ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
44 ; GFX908-NEXT: ret void
46 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe(
47 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
48 ; GFX90A-NEXT: ret void
50 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe(
51 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
52 ; GFX940-NEXT: ret void
54 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe(
55 ; GFX11-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
56 ; GFX11-NEXT: ret void
58 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value syncscope("wavefront") monotonic
62 define float @test_atomicrmw_fadd_f32_global_unsafe(ptr addrspace(1) %ptr, float %value) #0 {
63 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_unsafe(
64 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
65 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
66 ; CI: atomicrmw.start:
67 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
68 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
69 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
70 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
71 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
72 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
73 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
74 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
75 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
77 ; CI-NEXT: ret float [[TMP5]]
79 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_unsafe(
80 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
81 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
82 ; GFX9: atomicrmw.start:
83 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
84 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
85 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
86 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
87 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
88 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
89 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
90 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
91 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
92 ; GFX9: atomicrmw.end:
93 ; GFX9-NEXT: ret float [[TMP5]]
95 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_unsafe(
96 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
97 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
98 ; GFX908: atomicrmw.start:
99 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
100 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
101 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
102 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
103 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
104 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
105 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
106 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
107 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
108 ; GFX908: atomicrmw.end:
109 ; GFX908-NEXT: ret float [[TMP5]]
111 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_unsafe(
112 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
113 ; GFX90A-NEXT: ret float [[RES]]
115 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_unsafe(
116 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
117 ; GFX940-NEXT: ret float [[RES]]
119 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_unsafe(
120 ; GFX11-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
121 ; GFX11-NEXT: ret float [[RES]]
123 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value syncscope("wavefront") monotonic
127 define double @test_atomicrmw_fadd_f64_global_unsafe(ptr addrspace(1) %ptr, double %value) #0 {
128 ; CI-LABEL: @test_atomicrmw_fadd_f64_global_unsafe(
129 ; CI-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
130 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
131 ; CI: atomicrmw.start:
132 ; CI-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
133 ; CI-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
134 ; CI-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
135 ; CI-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
136 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
137 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
138 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
139 ; CI-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
140 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
142 ; CI-NEXT: ret double [[TMP5]]
144 ; GFX9-LABEL: @test_atomicrmw_fadd_f64_global_unsafe(
145 ; GFX9-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
146 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
147 ; GFX9: atomicrmw.start:
148 ; GFX9-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
149 ; GFX9-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
150 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
151 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
152 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
153 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
154 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
155 ; GFX9-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
156 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
157 ; GFX9: atomicrmw.end:
158 ; GFX9-NEXT: ret double [[TMP5]]
160 ; GFX908-LABEL: @test_atomicrmw_fadd_f64_global_unsafe(
161 ; GFX908-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
162 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
163 ; GFX908: atomicrmw.start:
164 ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
165 ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
166 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
167 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
168 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
169 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
170 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
171 ; GFX908-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
172 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
173 ; GFX908: atomicrmw.end:
174 ; GFX908-NEXT: ret double [[TMP5]]
176 ; GFX90A-LABEL: @test_atomicrmw_fadd_f64_global_unsafe(
177 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], double [[VALUE:%.*]] syncscope("wavefront") monotonic, align 8
178 ; GFX90A-NEXT: ret double [[RES]]
180 ; GFX940-LABEL: @test_atomicrmw_fadd_f64_global_unsafe(
181 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], double [[VALUE:%.*]] syncscope("wavefront") monotonic, align 8
182 ; GFX940-NEXT: ret double [[RES]]
184 ; GFX11-LABEL: @test_atomicrmw_fadd_f64_global_unsafe(
185 ; GFX11-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
186 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
187 ; GFX11: atomicrmw.start:
188 ; GFX11-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
189 ; GFX11-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
190 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
191 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
192 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
193 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
194 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
195 ; GFX11-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
196 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
197 ; GFX11: atomicrmw.end:
198 ; GFX11-NEXT: ret double [[TMP5]]
200 %res = atomicrmw fadd ptr addrspace(1) %ptr, double %value syncscope("wavefront") monotonic
204 define float @test_atomicrmw_fadd_f32_flat_unsafe(ptr %ptr, float %value) #0 {
205 ; CI-LABEL: @test_atomicrmw_fadd_f32_flat_unsafe(
206 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
207 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
208 ; CI: atomicrmw.start:
209 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
210 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
211 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
212 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
213 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
214 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
215 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
216 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
217 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
219 ; CI-NEXT: ret float [[TMP5]]
221 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_flat_unsafe(
222 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
223 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
224 ; GFX9: atomicrmw.start:
225 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
226 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
227 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
228 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
229 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
230 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
231 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
232 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
233 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
234 ; GFX9: atomicrmw.end:
235 ; GFX9-NEXT: ret float [[TMP5]]
237 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_flat_unsafe(
238 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
239 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
240 ; GFX908: atomicrmw.start:
241 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
242 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
243 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
244 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
245 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
246 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
247 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
248 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
249 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
250 ; GFX908: atomicrmw.end:
251 ; GFX908-NEXT: ret float [[TMP5]]
253 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_flat_unsafe(
254 ; GFX90A-NEXT: br label [[ATOMICRMW_CHECK_SHARED:%.*]]
255 ; GFX90A: atomicrmw.check.shared:
256 ; GFX90A-NEXT: [[IS_SHARED:%.*]] = call i1 @llvm.amdgcn.is.shared(ptr [[PTR:%.*]])
257 ; GFX90A-NEXT: br i1 [[IS_SHARED]], label [[ATOMICRMW_SHARED:%.*]], label [[ATOMICRMW_CHECK_PRIVATE:%.*]]
258 ; GFX90A: atomicrmw.shared:
259 ; GFX90A-NEXT: [[TMP1:%.*]] = addrspacecast ptr [[PTR]] to ptr addrspace(3)
260 ; GFX90A-NEXT: [[TMP2:%.*]] = atomicrmw fadd ptr addrspace(3) [[TMP1]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
261 ; GFX90A-NEXT: br label [[ATOMICRMW_PHI:%.*]]
262 ; GFX90A: atomicrmw.check.private:
263 ; GFX90A-NEXT: [[IS_PRIVATE:%.*]] = call i1 @llvm.amdgcn.is.private(ptr [[PTR]])
264 ; GFX90A-NEXT: br i1 [[IS_PRIVATE]], label [[ATOMICRMW_PRIVATE:%.*]], label [[ATOMICRMW_GLOBAL:%.*]]
265 ; GFX90A: atomicrmw.private:
266 ; GFX90A-NEXT: [[TMP3:%.*]] = addrspacecast ptr [[PTR]] to ptr addrspace(5)
267 ; GFX90A-NEXT: [[LOADED_PRIVATE:%.*]] = load float, ptr addrspace(5) [[TMP3]], align 4
268 ; GFX90A-NEXT: [[VAL_NEW:%.*]] = fadd float [[LOADED_PRIVATE]], [[VALUE]]
269 ; GFX90A-NEXT: store float [[VAL_NEW]], ptr addrspace(5) [[TMP3]], align 4
270 ; GFX90A-NEXT: br label [[ATOMICRMW_PHI]]
271 ; GFX90A: atomicrmw.global:
272 ; GFX90A-NEXT: [[TMP4:%.*]] = addrspacecast ptr [[PTR]] to ptr addrspace(1)
273 ; GFX90A-NEXT: [[TMP5:%.*]] = atomicrmw fadd ptr addrspace(1) [[TMP4]], float [[VALUE]] syncscope("wavefront") monotonic, align 4
274 ; GFX90A-NEXT: br label [[ATOMICRMW_PHI]]
275 ; GFX90A: atomicrmw.phi:
276 ; GFX90A-NEXT: [[LOADED_PHI:%.*]] = phi float [ [[TMP2]], [[ATOMICRMW_SHARED]] ], [ [[LOADED_PRIVATE]], [[ATOMICRMW_PRIVATE]] ], [ [[TMP5]], [[ATOMICRMW_GLOBAL]] ]
277 ; GFX90A-NEXT: br label [[ATOMICRMW_END:%.*]]
278 ; GFX90A: atomicrmw.end:
279 ; GFX90A-NEXT: ret float [[LOADED_PHI]]
281 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_flat_unsafe(
282 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
283 ; GFX940-NEXT: ret float [[RES]]
285 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_flat_unsafe(
286 ; GFX11-NEXT: [[RES:%.*]] = atomicrmw fadd ptr [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
287 ; GFX11-NEXT: ret float [[RES]]
289 %res = atomicrmw fadd ptr %ptr, float %value syncscope("wavefront") monotonic
293 define double @test_atomicrmw_fadd_f64_flat_unsafe(ptr %ptr, double %value) #0 {
294 ; CI-LABEL: @test_atomicrmw_fadd_f64_flat_unsafe(
295 ; CI-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
296 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
297 ; CI: atomicrmw.start:
298 ; CI-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
299 ; CI-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
300 ; CI-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
301 ; CI-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
302 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
303 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
304 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
305 ; CI-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
306 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
308 ; CI-NEXT: ret double [[TMP5]]
310 ; GFX9-LABEL: @test_atomicrmw_fadd_f64_flat_unsafe(
311 ; GFX9-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
312 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
313 ; GFX9: atomicrmw.start:
314 ; GFX9-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
315 ; GFX9-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
316 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
317 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
318 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
319 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
320 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
321 ; GFX9-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
322 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
323 ; GFX9: atomicrmw.end:
324 ; GFX9-NEXT: ret double [[TMP5]]
326 ; GFX908-LABEL: @test_atomicrmw_fadd_f64_flat_unsafe(
327 ; GFX908-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
328 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
329 ; GFX908: atomicrmw.start:
330 ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
331 ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
332 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
333 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
334 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
335 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
336 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
337 ; GFX908-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
338 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
339 ; GFX908: atomicrmw.end:
340 ; GFX908-NEXT: ret double [[TMP5]]
342 ; GFX90A-LABEL: @test_atomicrmw_fadd_f64_flat_unsafe(
343 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr [[PTR:%.*]], double [[VALUE:%.*]] syncscope("wavefront") monotonic, align 8
344 ; GFX90A-NEXT: ret double [[RES]]
346 ; GFX940-LABEL: @test_atomicrmw_fadd_f64_flat_unsafe(
347 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr [[PTR:%.*]], double [[VALUE:%.*]] syncscope("wavefront") monotonic, align 8
348 ; GFX940-NEXT: ret double [[RES]]
350 ; GFX11-LABEL: @test_atomicrmw_fadd_f64_flat_unsafe(
351 ; GFX11-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
352 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
353 ; GFX11: atomicrmw.start:
354 ; GFX11-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
355 ; GFX11-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
356 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
357 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
358 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
359 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
360 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
361 ; GFX11-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
362 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
363 ; GFX11: atomicrmw.end:
364 ; GFX11-NEXT: ret double [[TMP5]]
366 %res = atomicrmw fadd ptr %ptr, double %value syncscope("wavefront") monotonic
370 define float @test_atomicrmw_fadd_f32_flat(ptr %ptr, float %value) {
371 ; CI-LABEL: @test_atomicrmw_fadd_f32_flat(
372 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
373 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
374 ; CI: atomicrmw.start:
375 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
376 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
377 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
378 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
379 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
380 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
381 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
382 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
383 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
385 ; CI-NEXT: ret float [[TMP5]]
387 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_flat(
388 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
389 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
390 ; GFX9: atomicrmw.start:
391 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
392 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
393 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
394 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
395 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
396 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
397 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
398 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
399 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
400 ; GFX9: atomicrmw.end:
401 ; GFX9-NEXT: ret float [[TMP5]]
403 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_flat(
404 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
405 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
406 ; GFX908: atomicrmw.start:
407 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
408 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
409 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
410 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
411 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
412 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
413 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
414 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
415 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
416 ; GFX908: atomicrmw.end:
417 ; GFX908-NEXT: ret float [[TMP5]]
419 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_flat(
420 ; GFX90A-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
421 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
422 ; GFX90A: atomicrmw.start:
423 ; GFX90A-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
424 ; GFX90A-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
425 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
426 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
427 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
428 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
429 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
430 ; GFX90A-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
431 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
432 ; GFX90A: atomicrmw.end:
433 ; GFX90A-NEXT: ret float [[TMP5]]
435 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_flat(
436 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
437 ; GFX940-NEXT: ret float [[RES]]
439 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_flat(
440 ; GFX11-NEXT: [[TMP1:%.*]] = load float, ptr [[PTR:%.*]], align 4
441 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
442 ; GFX11: atomicrmw.start:
443 ; GFX11-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
444 ; GFX11-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
445 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
446 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
447 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
448 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
449 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
450 ; GFX11-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
451 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
452 ; GFX11: atomicrmw.end:
453 ; GFX11-NEXT: ret float [[TMP5]]
455 %res = atomicrmw fadd ptr %ptr, float %value seq_cst
459 define float @test_atomicrmw_fadd_f32_global(ptr addrspace(1) %ptr, float %value) {
460 ; CI-LABEL: @test_atomicrmw_fadd_f32_global(
461 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
462 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
463 ; CI: atomicrmw.start:
464 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
465 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
466 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
467 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
468 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
469 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
470 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
471 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
472 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
474 ; CI-NEXT: ret float [[TMP5]]
476 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global(
477 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
478 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
479 ; GFX9: atomicrmw.start:
480 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
481 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
482 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
483 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
484 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
485 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
486 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
487 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
488 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
489 ; GFX9: atomicrmw.end:
490 ; GFX9-NEXT: ret float [[TMP5]]
492 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global(
493 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
494 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
495 ; GFX908: atomicrmw.start:
496 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
497 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
498 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
499 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
500 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
501 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
502 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
503 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
504 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
505 ; GFX908: atomicrmw.end:
506 ; GFX908-NEXT: ret float [[TMP5]]
508 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global(
509 ; GFX90A-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
510 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
511 ; GFX90A: atomicrmw.start:
512 ; GFX90A-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
513 ; GFX90A-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
514 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
515 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
516 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
517 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
518 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
519 ; GFX90A-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
520 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
521 ; GFX90A: atomicrmw.end:
522 ; GFX90A-NEXT: ret float [[TMP5]]
524 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global(
525 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
526 ; GFX940-NEXT: ret float [[RES]]
528 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global(
529 ; GFX11-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
530 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
531 ; GFX11: atomicrmw.start:
532 ; GFX11-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
533 ; GFX11-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
534 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
535 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
536 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
537 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
538 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
539 ; GFX11-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
540 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
541 ; GFX11: atomicrmw.end:
542 ; GFX11-NEXT: ret float [[TMP5]]
544 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value seq_cst
548 define void @test_atomicrmw_fadd_f32_global_no_use_ieee(ptr addrspace(1) %ptr, float %value) {
549 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_no_use_ieee(
550 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
551 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
552 ; CI: atomicrmw.start:
553 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
554 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
555 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
556 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
557 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
558 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
559 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
560 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
561 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
565 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_no_use_ieee(
566 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
567 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
568 ; GFX9: atomicrmw.start:
569 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
570 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
571 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
572 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
573 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
574 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
575 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
576 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
577 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
578 ; GFX9: atomicrmw.end:
579 ; GFX9-NEXT: ret void
581 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_no_use_ieee(
582 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
583 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
584 ; GFX908: atomicrmw.start:
585 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
586 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
587 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
588 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
589 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
590 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
591 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
592 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
593 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
594 ; GFX908: atomicrmw.end:
595 ; GFX908-NEXT: ret void
597 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_no_use_ieee(
598 ; GFX90A-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
599 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
600 ; GFX90A: atomicrmw.start:
601 ; GFX90A-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
602 ; GFX90A-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
603 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
604 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
605 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
606 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
607 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
608 ; GFX90A-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
609 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
610 ; GFX90A: atomicrmw.end:
611 ; GFX90A-NEXT: ret void
613 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_no_use_ieee(
614 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
615 ; GFX940-NEXT: ret void
617 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_no_use_ieee(
618 ; GFX11-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
619 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
620 ; GFX11: atomicrmw.start:
621 ; GFX11-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
622 ; GFX11-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
623 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
624 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
625 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
626 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
627 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
628 ; GFX11-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
629 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
630 ; GFX11: atomicrmw.end:
631 ; GFX11-NEXT: ret void
633 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value seq_cst
637 define void @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(ptr addrspace(1) %ptr, float %value) #0 {
638 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(
639 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
640 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
641 ; CI: atomicrmw.start:
642 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
643 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
644 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
645 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
646 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
647 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
648 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
649 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
650 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
654 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(
655 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
656 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
657 ; GFX9: atomicrmw.start:
658 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
659 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
660 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
661 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
662 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
663 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
664 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
665 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
666 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
667 ; GFX9: atomicrmw.end:
668 ; GFX9-NEXT: ret void
670 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(
671 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
672 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
673 ; GFX908: atomicrmw.start:
674 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
675 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
676 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
677 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
678 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
679 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
680 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
681 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
682 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
683 ; GFX908: atomicrmw.end:
684 ; GFX908-NEXT: ret void
686 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(
687 ; GFX90A-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
688 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
689 ; GFX90A: atomicrmw.start:
690 ; GFX90A-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
691 ; GFX90A-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
692 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
693 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
694 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
695 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
696 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
697 ; GFX90A-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
698 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
699 ; GFX90A: atomicrmw.end:
700 ; GFX90A-NEXT: ret void
702 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(
703 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
704 ; GFX940-NEXT: ret void
706 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_no_use_denorm_flush(
707 ; GFX11-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
708 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
709 ; GFX11: atomicrmw.start:
710 ; GFX11-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
711 ; GFX11-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
712 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
713 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
714 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
715 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
716 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
717 ; GFX11-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
718 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
719 ; GFX11: atomicrmw.end:
720 ; GFX11-NEXT: ret void
722 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value seq_cst
726 define float @test_atomicrmw_fadd_f32_local(ptr addrspace(3) %ptr, float %value) {
727 ; CI-LABEL: @test_atomicrmw_fadd_f32_local(
728 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(3) [[PTR:%.*]], align 4
729 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
730 ; CI: atomicrmw.start:
731 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
732 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
733 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
734 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
735 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
736 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
737 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
738 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
739 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
741 ; CI-NEXT: ret float [[TMP5]]
743 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_local(
744 ; GFX9-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
745 ; GFX9-NEXT: ret float [[RES]]
747 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_local(
748 ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
749 ; GFX908-NEXT: ret float [[RES]]
751 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_local(
752 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
753 ; GFX90A-NEXT: ret float [[RES]]
755 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_local(
756 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
757 ; GFX940-NEXT: ret float [[RES]]
759 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_local(
760 ; GFX11-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
761 ; GFX11-NEXT: ret float [[RES]]
763 %res = atomicrmw fadd ptr addrspace(3) %ptr, float %value seq_cst
767 define half @test_atomicrmw_fadd_f16_flat(ptr %ptr, half %value) {
768 ; CI-LABEL: @test_atomicrmw_fadd_f16_flat(
769 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
770 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
771 ; CI-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
772 ; CI-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
773 ; CI-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
774 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
775 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
776 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
777 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
778 ; CI: atomicrmw.start:
779 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
780 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
781 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
782 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
783 ; CI-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
784 ; CI-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
785 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
786 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
787 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
788 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
789 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
790 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
791 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
792 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
794 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
795 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
796 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
797 ; CI-NEXT: ret half [[TMP7]]
799 ; GFX9-LABEL: @test_atomicrmw_fadd_f16_flat(
800 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
801 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
802 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
803 ; GFX9-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
804 ; GFX9-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
805 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
806 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
807 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
808 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
809 ; GFX9: atomicrmw.start:
810 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
811 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
812 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
813 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
814 ; GFX9-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
815 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
816 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
817 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
818 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
819 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
820 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
821 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
822 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
823 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
824 ; GFX9: atomicrmw.end:
825 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
826 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
827 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
828 ; GFX9-NEXT: ret half [[TMP7]]
830 ; GFX908-LABEL: @test_atomicrmw_fadd_f16_flat(
831 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
832 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
833 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
834 ; GFX908-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
835 ; GFX908-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
836 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
837 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
838 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
839 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
840 ; GFX908: atomicrmw.start:
841 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
842 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
843 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
844 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
845 ; GFX908-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
846 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
847 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
848 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
849 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
850 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
851 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
852 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
853 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
854 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
855 ; GFX908: atomicrmw.end:
856 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
857 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
858 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
859 ; GFX908-NEXT: ret half [[TMP7]]
861 ; GFX90A-LABEL: @test_atomicrmw_fadd_f16_flat(
862 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
863 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
864 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
865 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
866 ; GFX90A-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
867 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
868 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
869 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
870 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
871 ; GFX90A: atomicrmw.start:
872 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
873 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
874 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
875 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
876 ; GFX90A-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
877 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
878 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
879 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
880 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
881 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
882 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
883 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
884 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
885 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
886 ; GFX90A: atomicrmw.end:
887 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
888 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
889 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
890 ; GFX90A-NEXT: ret half [[TMP7]]
892 ; GFX940-LABEL: @test_atomicrmw_fadd_f16_flat(
893 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
894 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
895 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
896 ; GFX940-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
897 ; GFX940-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
898 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
899 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
900 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
901 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
902 ; GFX940: atomicrmw.start:
903 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
904 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
905 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
906 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
907 ; GFX940-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
908 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
909 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
910 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
911 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
912 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
913 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
914 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
915 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
916 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
917 ; GFX940: atomicrmw.end:
918 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
919 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
920 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
921 ; GFX940-NEXT: ret half [[TMP7]]
923 ; GFX11-LABEL: @test_atomicrmw_fadd_f16_flat(
924 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
925 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
926 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
927 ; GFX11-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
928 ; GFX11-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
929 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
930 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
931 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
932 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
933 ; GFX11: atomicrmw.start:
934 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
935 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
936 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
937 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
938 ; GFX11-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
939 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
940 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
941 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
942 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
943 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
944 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
945 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
946 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
947 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
948 ; GFX11: atomicrmw.end:
949 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
950 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
951 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
952 ; GFX11-NEXT: ret half [[TMP7]]
954 %res = atomicrmw fadd ptr %ptr, half %value seq_cst
958 define half @test_atomicrmw_fadd_f16_global(ptr addrspace(1) %ptr, half %value) {
959 ; CI-LABEL: @test_atomicrmw_fadd_f16_global(
960 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
961 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
962 ; CI-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
963 ; CI-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
964 ; CI-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
965 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
966 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
967 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
968 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
969 ; CI: atomicrmw.start:
970 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
971 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
972 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
973 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
974 ; CI-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
975 ; CI-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
976 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
977 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
978 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
979 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
980 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
981 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
982 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
983 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
985 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
986 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
987 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
988 ; CI-NEXT: ret half [[TMP7]]
990 ; GFX9-LABEL: @test_atomicrmw_fadd_f16_global(
991 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
992 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
993 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
994 ; GFX9-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
995 ; GFX9-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
996 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
997 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
998 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
999 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1000 ; GFX9: atomicrmw.start:
1001 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1002 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
1003 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1004 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1005 ; GFX9-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1006 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1007 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1008 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
1009 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1010 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1011 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1012 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1013 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1014 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1015 ; GFX9: atomicrmw.end:
1016 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
1017 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1018 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1019 ; GFX9-NEXT: ret half [[TMP7]]
1021 ; GFX908-LABEL: @test_atomicrmw_fadd_f16_global(
1022 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
1023 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
1024 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
1025 ; GFX908-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
1026 ; GFX908-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
1027 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
1028 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1029 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
1030 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1031 ; GFX908: atomicrmw.start:
1032 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1033 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
1034 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1035 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1036 ; GFX908-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1037 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1038 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1039 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
1040 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1041 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1042 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1043 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1044 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1045 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1046 ; GFX908: atomicrmw.end:
1047 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
1048 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1049 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1050 ; GFX908-NEXT: ret half [[TMP7]]
1052 ; GFX90A-LABEL: @test_atomicrmw_fadd_f16_global(
1053 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
1054 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
1055 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
1056 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
1057 ; GFX90A-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
1058 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
1059 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1060 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
1061 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1062 ; GFX90A: atomicrmw.start:
1063 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1064 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
1065 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1066 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1067 ; GFX90A-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1068 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1069 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1070 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
1071 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1072 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1073 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1074 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1075 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1076 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1077 ; GFX90A: atomicrmw.end:
1078 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
1079 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1080 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1081 ; GFX90A-NEXT: ret half [[TMP7]]
1083 ; GFX940-LABEL: @test_atomicrmw_fadd_f16_global(
1084 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
1085 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
1086 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
1087 ; GFX940-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
1088 ; GFX940-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
1089 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
1090 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1091 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
1092 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
1093 ; GFX940: atomicrmw.start:
1094 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1095 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
1096 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1097 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1098 ; GFX940-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1099 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1100 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1101 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
1102 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1103 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1104 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1105 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1106 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1107 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1108 ; GFX940: atomicrmw.end:
1109 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
1110 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1111 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1112 ; GFX940-NEXT: ret half [[TMP7]]
1114 ; GFX11-LABEL: @test_atomicrmw_fadd_f16_global(
1115 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
1116 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
1117 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
1118 ; GFX11-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
1119 ; GFX11-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
1120 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
1121 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1122 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
1123 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1124 ; GFX11: atomicrmw.start:
1125 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1126 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
1127 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1128 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1129 ; GFX11-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1130 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1131 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1132 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
1133 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1134 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1135 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1136 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1137 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1138 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1139 ; GFX11: atomicrmw.end:
1140 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
1141 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1142 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1143 ; GFX11-NEXT: ret half [[TMP7]]
1145 %res = atomicrmw fadd ptr addrspace(1) %ptr, half %value seq_cst
1149 define half @test_atomicrmw_fadd_f16_global_align4(ptr addrspace(1) %ptr, half %value) {
1150 ; CI-LABEL: @test_atomicrmw_fadd_f16_global_align4(
1151 ; CI-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
1152 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1153 ; CI: atomicrmw.start:
1154 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1155 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
1156 ; CI-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to half
1157 ; CI-NEXT: [[NEW:%.*]] = fadd half [[TMP2]], [[VALUE:%.*]]
1158 ; CI-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
1159 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
1160 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
1161 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
1162 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1163 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1164 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
1165 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1166 ; CI: atomicrmw.end:
1167 ; CI-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
1168 ; CI-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to half
1169 ; CI-NEXT: ret half [[TMP5]]
1171 ; GFX9-LABEL: @test_atomicrmw_fadd_f16_global_align4(
1172 ; GFX9-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
1173 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1174 ; GFX9: atomicrmw.start:
1175 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1176 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
1177 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to half
1178 ; GFX9-NEXT: [[NEW:%.*]] = fadd half [[TMP2]], [[VALUE:%.*]]
1179 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
1180 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
1181 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
1182 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
1183 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1184 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1185 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
1186 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1187 ; GFX9: atomicrmw.end:
1188 ; GFX9-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
1189 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to half
1190 ; GFX9-NEXT: ret half [[TMP5]]
1192 ; GFX908-LABEL: @test_atomicrmw_fadd_f16_global_align4(
1193 ; GFX908-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
1194 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1195 ; GFX908: atomicrmw.start:
1196 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1197 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
1198 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to half
1199 ; GFX908-NEXT: [[NEW:%.*]] = fadd half [[TMP2]], [[VALUE:%.*]]
1200 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
1201 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
1202 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
1203 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
1204 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1205 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1206 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
1207 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1208 ; GFX908: atomicrmw.end:
1209 ; GFX908-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
1210 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to half
1211 ; GFX908-NEXT: ret half [[TMP5]]
1213 ; GFX90A-LABEL: @test_atomicrmw_fadd_f16_global_align4(
1214 ; GFX90A-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
1215 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1216 ; GFX90A: atomicrmw.start:
1217 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1218 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
1219 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to half
1220 ; GFX90A-NEXT: [[NEW:%.*]] = fadd half [[TMP2]], [[VALUE:%.*]]
1221 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
1222 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
1223 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
1224 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
1225 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1226 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1227 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
1228 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1229 ; GFX90A: atomicrmw.end:
1230 ; GFX90A-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
1231 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to half
1232 ; GFX90A-NEXT: ret half [[TMP5]]
1234 ; GFX940-LABEL: @test_atomicrmw_fadd_f16_global_align4(
1235 ; GFX940-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
1236 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
1237 ; GFX940: atomicrmw.start:
1238 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1239 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
1240 ; GFX940-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to half
1241 ; GFX940-NEXT: [[NEW:%.*]] = fadd half [[TMP2]], [[VALUE:%.*]]
1242 ; GFX940-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
1243 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
1244 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
1245 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
1246 ; GFX940-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1247 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1248 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
1249 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1250 ; GFX940: atomicrmw.end:
1251 ; GFX940-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
1252 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to half
1253 ; GFX940-NEXT: ret half [[TMP5]]
1255 ; GFX11-LABEL: @test_atomicrmw_fadd_f16_global_align4(
1256 ; GFX11-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
1257 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1258 ; GFX11: atomicrmw.start:
1259 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1260 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
1261 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to half
1262 ; GFX11-NEXT: [[NEW:%.*]] = fadd half [[TMP2]], [[VALUE:%.*]]
1263 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast half [[NEW]] to i16
1264 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
1265 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
1266 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
1267 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1268 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1269 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
1270 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1271 ; GFX11: atomicrmw.end:
1272 ; GFX11-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
1273 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to half
1274 ; GFX11-NEXT: ret half [[TMP5]]
1276 %res = atomicrmw fadd ptr addrspace(1) %ptr, half %value seq_cst, align 4
1280 define half @test_atomicrmw_fadd_f16_local(ptr addrspace(3) %ptr, half %value) {
1281 ; CI-LABEL: @test_atomicrmw_fadd_f16_local(
1282 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
1283 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
1284 ; CI-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
1285 ; CI-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
1286 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
1287 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1288 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
1289 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1290 ; CI: atomicrmw.start:
1291 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1292 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
1293 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1294 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1295 ; CI-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1296 ; CI-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1297 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1298 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
1299 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1300 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1301 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1302 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1303 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1304 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1305 ; CI: atomicrmw.end:
1306 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
1307 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1308 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1309 ; CI-NEXT: ret half [[TMP7]]
1311 ; GFX9-LABEL: @test_atomicrmw_fadd_f16_local(
1312 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
1313 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
1314 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
1315 ; GFX9-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
1316 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
1317 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1318 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
1319 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1320 ; GFX9: atomicrmw.start:
1321 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1322 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
1323 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1324 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1325 ; GFX9-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1326 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1327 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1328 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
1329 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1330 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1331 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1332 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1333 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1334 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1335 ; GFX9: atomicrmw.end:
1336 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
1337 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1338 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1339 ; GFX9-NEXT: ret half [[TMP7]]
1341 ; GFX908-LABEL: @test_atomicrmw_fadd_f16_local(
1342 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
1343 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
1344 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
1345 ; GFX908-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
1346 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
1347 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1348 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
1349 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1350 ; GFX908: atomicrmw.start:
1351 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1352 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
1353 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1354 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1355 ; GFX908-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1356 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1357 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1358 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
1359 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1360 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1361 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1362 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1363 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1364 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1365 ; GFX908: atomicrmw.end:
1366 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
1367 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1368 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1369 ; GFX908-NEXT: ret half [[TMP7]]
1371 ; GFX90A-LABEL: @test_atomicrmw_fadd_f16_local(
1372 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
1373 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
1374 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
1375 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
1376 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
1377 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1378 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
1379 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1380 ; GFX90A: atomicrmw.start:
1381 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1382 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
1383 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1384 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1385 ; GFX90A-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1386 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1387 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1388 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
1389 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1390 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1391 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1392 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1393 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1394 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1395 ; GFX90A: atomicrmw.end:
1396 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
1397 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1398 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1399 ; GFX90A-NEXT: ret half [[TMP7]]
1401 ; GFX940-LABEL: @test_atomicrmw_fadd_f16_local(
1402 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
1403 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
1404 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
1405 ; GFX940-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
1406 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
1407 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1408 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
1409 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
1410 ; GFX940: atomicrmw.start:
1411 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1412 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
1413 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1414 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1415 ; GFX940-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1416 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1417 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1418 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
1419 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1420 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1421 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1422 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1423 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1424 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1425 ; GFX940: atomicrmw.end:
1426 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
1427 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1428 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1429 ; GFX940-NEXT: ret half [[TMP7]]
1431 ; GFX11-LABEL: @test_atomicrmw_fadd_f16_local(
1432 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
1433 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
1434 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
1435 ; GFX11-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
1436 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
1437 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
1438 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
1439 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1440 ; GFX11: atomicrmw.start:
1441 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
1442 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
1443 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
1444 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to half
1445 ; GFX11-NEXT: [[NEW:%.*]] = fadd half [[TMP4]], [[VALUE:%.*]]
1446 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast half [[NEW]] to i16
1447 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
1448 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
1449 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
1450 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
1451 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] seq_cst seq_cst, align 4
1452 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
1453 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
1454 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1455 ; GFX11: atomicrmw.end:
1456 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
1457 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
1458 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to half
1459 ; GFX11-NEXT: ret half [[TMP7]]
1461 %res = atomicrmw fadd ptr addrspace(3) %ptr, half %value seq_cst
1465 define double @test_atomicrmw_fadd_f64_flat(ptr %ptr, double %value) {
1466 ; CI-LABEL: @test_atomicrmw_fadd_f64_flat(
1467 ; CI-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
1468 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1469 ; CI: atomicrmw.start:
1470 ; CI-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1471 ; CI-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1472 ; CI-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1473 ; CI-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1474 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1475 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1476 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1477 ; CI-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1478 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1479 ; CI: atomicrmw.end:
1480 ; CI-NEXT: ret double [[TMP5]]
1482 ; GFX9-LABEL: @test_atomicrmw_fadd_f64_flat(
1483 ; GFX9-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
1484 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1485 ; GFX9: atomicrmw.start:
1486 ; GFX9-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1487 ; GFX9-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1488 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1489 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1490 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1491 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1492 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1493 ; GFX9-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1494 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1495 ; GFX9: atomicrmw.end:
1496 ; GFX9-NEXT: ret double [[TMP5]]
1498 ; GFX908-LABEL: @test_atomicrmw_fadd_f64_flat(
1499 ; GFX908-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
1500 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1501 ; GFX908: atomicrmw.start:
1502 ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1503 ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1504 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1505 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1506 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1507 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1508 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1509 ; GFX908-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1510 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1511 ; GFX908: atomicrmw.end:
1512 ; GFX908-NEXT: ret double [[TMP5]]
1514 ; GFX90A-LABEL: @test_atomicrmw_fadd_f64_flat(
1515 ; GFX90A-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
1516 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1517 ; GFX90A: atomicrmw.start:
1518 ; GFX90A-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1519 ; GFX90A-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1520 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1521 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1522 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1523 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1524 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1525 ; GFX90A-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1526 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1527 ; GFX90A: atomicrmw.end:
1528 ; GFX90A-NEXT: ret double [[TMP5]]
1530 ; GFX940-LABEL: @test_atomicrmw_fadd_f64_flat(
1531 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr [[PTR:%.*]], double [[VALUE:%.*]] seq_cst, align 8
1532 ; GFX940-NEXT: ret double [[RES]]
1534 ; GFX11-LABEL: @test_atomicrmw_fadd_f64_flat(
1535 ; GFX11-NEXT: [[TMP1:%.*]] = load double, ptr [[PTR:%.*]], align 8
1536 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1537 ; GFX11: atomicrmw.start:
1538 ; GFX11-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1539 ; GFX11-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1540 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1541 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1542 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1543 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1544 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1545 ; GFX11-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1546 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1547 ; GFX11: atomicrmw.end:
1548 ; GFX11-NEXT: ret double [[TMP5]]
1550 %res = atomicrmw fadd ptr %ptr, double %value seq_cst
1554 define double @test_atomicrmw_fadd_f64_global(ptr addrspace(1) %ptr, double %value) {
1555 ; CI-LABEL: @test_atomicrmw_fadd_f64_global(
1556 ; CI-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1557 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1558 ; CI: atomicrmw.start:
1559 ; CI-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1560 ; CI-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1561 ; CI-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1562 ; CI-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1563 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1564 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1565 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1566 ; CI-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1567 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1568 ; CI: atomicrmw.end:
1569 ; CI-NEXT: ret double [[TMP5]]
1571 ; GFX9-LABEL: @test_atomicrmw_fadd_f64_global(
1572 ; GFX9-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1573 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1574 ; GFX9: atomicrmw.start:
1575 ; GFX9-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1576 ; GFX9-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1577 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1578 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1579 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1580 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1581 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1582 ; GFX9-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1583 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1584 ; GFX9: atomicrmw.end:
1585 ; GFX9-NEXT: ret double [[TMP5]]
1587 ; GFX908-LABEL: @test_atomicrmw_fadd_f64_global(
1588 ; GFX908-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1589 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1590 ; GFX908: atomicrmw.start:
1591 ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1592 ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1593 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1594 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1595 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1596 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1597 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1598 ; GFX908-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1599 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1600 ; GFX908: atomicrmw.end:
1601 ; GFX908-NEXT: ret double [[TMP5]]
1603 ; GFX90A-LABEL: @test_atomicrmw_fadd_f64_global(
1604 ; GFX90A-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1605 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1606 ; GFX90A: atomicrmw.start:
1607 ; GFX90A-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1608 ; GFX90A-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1609 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1610 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1611 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1612 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1613 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1614 ; GFX90A-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1615 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1616 ; GFX90A: atomicrmw.end:
1617 ; GFX90A-NEXT: ret double [[TMP5]]
1619 ; GFX940-LABEL: @test_atomicrmw_fadd_f64_global(
1620 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], double [[VALUE:%.*]] seq_cst, align 8
1621 ; GFX940-NEXT: ret double [[RES]]
1623 ; GFX11-LABEL: @test_atomicrmw_fadd_f64_global(
1624 ; GFX11-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1625 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1626 ; GFX11: atomicrmw.start:
1627 ; GFX11-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1628 ; GFX11-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1629 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1630 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1631 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1632 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1633 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1634 ; GFX11-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1635 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1636 ; GFX11: atomicrmw.end:
1637 ; GFX11-NEXT: ret double [[TMP5]]
1639 %res = atomicrmw fadd ptr addrspace(1) %ptr, double %value seq_cst
1643 define double @test_atomicrmw_fadd_f64_local(ptr addrspace(3) %ptr, double %value) {
1644 ; CI-LABEL: @test_atomicrmw_fadd_f64_local(
1645 ; CI-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(3) [[PTR:%.*]], align 8
1646 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1647 ; CI: atomicrmw.start:
1648 ; CI-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1649 ; CI-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1650 ; CI-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1651 ; CI-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1652 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1653 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1654 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1655 ; CI-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1656 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1657 ; CI: atomicrmw.end:
1658 ; CI-NEXT: ret double [[TMP5]]
1660 ; GFX9-LABEL: @test_atomicrmw_fadd_f64_local(
1661 ; GFX9-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(3) [[PTR:%.*]], align 8
1662 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1663 ; GFX9: atomicrmw.start:
1664 ; GFX9-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1665 ; GFX9-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1666 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1667 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1668 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1669 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1670 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1671 ; GFX9-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1672 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1673 ; GFX9: atomicrmw.end:
1674 ; GFX9-NEXT: ret double [[TMP5]]
1676 ; GFX908-LABEL: @test_atomicrmw_fadd_f64_local(
1677 ; GFX908-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(3) [[PTR:%.*]], align 8
1678 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1679 ; GFX908: atomicrmw.start:
1680 ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1681 ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1682 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1683 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1684 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1685 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1686 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1687 ; GFX908-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1688 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1689 ; GFX908: atomicrmw.end:
1690 ; GFX908-NEXT: ret double [[TMP5]]
1692 ; GFX90A-LABEL: @test_atomicrmw_fadd_f64_local(
1693 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], double [[VALUE:%.*]] seq_cst, align 8
1694 ; GFX90A-NEXT: ret double [[RES]]
1696 ; GFX940-LABEL: @test_atomicrmw_fadd_f64_local(
1697 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], double [[VALUE:%.*]] seq_cst, align 8
1698 ; GFX940-NEXT: ret double [[RES]]
1700 ; GFX11-LABEL: @test_atomicrmw_fadd_f64_local(
1701 ; GFX11-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(3) [[PTR:%.*]], align 8
1702 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1703 ; GFX11: atomicrmw.start:
1704 ; GFX11-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1705 ; GFX11-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
1706 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1707 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1708 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] seq_cst seq_cst, align 8
1709 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1710 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1711 ; GFX11-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1712 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1713 ; GFX11: atomicrmw.end:
1714 ; GFX11-NEXT: ret double [[TMP5]]
1716 %res = atomicrmw fadd ptr addrspace(3) %ptr, double %value seq_cst
1720 define float @test_atomicrmw_fadd_f32_global_agent(ptr addrspace(1) %ptr, float %value) {
1721 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_agent(
1722 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1723 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1724 ; CI: atomicrmw.start:
1725 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1726 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1727 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1728 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1729 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("agent") monotonic monotonic, align 4
1730 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1731 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1732 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1733 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1734 ; CI: atomicrmw.end:
1735 ; CI-NEXT: ret float [[TMP5]]
1737 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_agent(
1738 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1739 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1740 ; GFX9: atomicrmw.start:
1741 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1742 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1743 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1744 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1745 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("agent") monotonic monotonic, align 4
1746 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1747 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1748 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1749 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1750 ; GFX9: atomicrmw.end:
1751 ; GFX9-NEXT: ret float [[TMP5]]
1753 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_agent(
1754 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1755 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1756 ; GFX908: atomicrmw.start:
1757 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1758 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1759 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1760 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1761 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("agent") monotonic monotonic, align 4
1762 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1763 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1764 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1765 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1766 ; GFX908: atomicrmw.end:
1767 ; GFX908-NEXT: ret float [[TMP5]]
1769 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_agent(
1770 ; GFX90A-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1771 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1772 ; GFX90A: atomicrmw.start:
1773 ; GFX90A-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1774 ; GFX90A-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1775 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1776 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1777 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("agent") monotonic monotonic, align 4
1778 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1779 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1780 ; GFX90A-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1781 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1782 ; GFX90A: atomicrmw.end:
1783 ; GFX90A-NEXT: ret float [[TMP5]]
1785 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_agent(
1786 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("agent") monotonic, align 4
1787 ; GFX940-NEXT: ret float [[RES]]
1789 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_agent(
1790 ; GFX11-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1791 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1792 ; GFX11: atomicrmw.start:
1793 ; GFX11-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1794 ; GFX11-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1795 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1796 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1797 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("agent") monotonic monotonic, align 4
1798 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1799 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1800 ; GFX11-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1801 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1802 ; GFX11: atomicrmw.end:
1803 ; GFX11-NEXT: ret float [[TMP5]]
1805 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value syncscope("agent") monotonic
1809 define float @test_atomicrmw_fadd_f32_global_one_as(ptr addrspace(1) %ptr, float %value) {
1810 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_one_as(
1811 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1812 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1813 ; CI: atomicrmw.start:
1814 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1815 ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1816 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1817 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1818 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("one-as") monotonic monotonic, align 4
1819 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1820 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1821 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1822 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1823 ; CI: atomicrmw.end:
1824 ; CI-NEXT: ret float [[TMP5]]
1826 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_one_as(
1827 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1828 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1829 ; GFX9: atomicrmw.start:
1830 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1831 ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1832 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1833 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1834 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("one-as") monotonic monotonic, align 4
1835 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1836 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1837 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1838 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1839 ; GFX9: atomicrmw.end:
1840 ; GFX9-NEXT: ret float [[TMP5]]
1842 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_one_as(
1843 ; GFX908-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1844 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1845 ; GFX908: atomicrmw.start:
1846 ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1847 ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1848 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1849 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1850 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("one-as") monotonic monotonic, align 4
1851 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1852 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1853 ; GFX908-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1854 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1855 ; GFX908: atomicrmw.end:
1856 ; GFX908-NEXT: ret float [[TMP5]]
1858 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_one_as(
1859 ; GFX90A-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1860 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
1861 ; GFX90A: atomicrmw.start:
1862 ; GFX90A-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1863 ; GFX90A-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1864 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1865 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1866 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("one-as") monotonic monotonic, align 4
1867 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1868 ; GFX90A-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1869 ; GFX90A-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1870 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1871 ; GFX90A: atomicrmw.end:
1872 ; GFX90A-NEXT: ret float [[TMP5]]
1874 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_one_as(
1875 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("one-as") monotonic, align 4
1876 ; GFX940-NEXT: ret float [[RES]]
1878 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_one_as(
1879 ; GFX11-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1880 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
1881 ; GFX11: atomicrmw.start:
1882 ; GFX11-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1883 ; GFX11-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
1884 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1885 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1886 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("one-as") monotonic monotonic, align 4
1887 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1888 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1889 ; GFX11-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1890 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1891 ; GFX11: atomicrmw.end:
1892 ; GFX11-NEXT: ret float [[TMP5]]
1894 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value syncscope("one-as") monotonic
1898 define void @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(ptr addrspace(1) %ptr, float %value) #1 {
1899 ; CI-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(
1900 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1901 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1902 ; CI: atomicrmw.start:
1903 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1904 ; CI-NEXT: [[NEW:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[LOADED]], float [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6:[0-9]+]]
1905 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1906 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1907 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
1908 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1909 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1910 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1911 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1912 ; CI: atomicrmw.end:
1915 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(
1916 ; GFX9-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(1) [[PTR:%.*]], align 4
1917 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1918 ; GFX9: atomicrmw.start:
1919 ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1920 ; GFX9-NEXT: [[NEW:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[LOADED]], float [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6:[0-9]+]]
1921 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
1922 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
1923 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 4
1924 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
1925 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
1926 ; GFX9-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
1927 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1928 ; GFX9: atomicrmw.end:
1929 ; GFX9-NEXT: ret void
1931 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(
1932 ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
1933 ; GFX908-NEXT: ret void
1935 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(
1936 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
1937 ; GFX90A-NEXT: ret void
1939 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(
1940 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
1941 ; GFX940-NEXT: ret void
1943 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_global_no_use_unsafe_structfp(
1944 ; GFX11-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], float [[VALUE:%.*]] syncscope("wavefront") monotonic, align 4
1945 ; GFX11-NEXT: ret void
1947 %res = atomicrmw fadd ptr addrspace(1) %ptr, float %value syncscope("wavefront") monotonic
1951 define double @test_atomicrmw_fadd_f64_global_unsafe_strictfp(ptr addrspace(1) %ptr, double %value) #1 {
1952 ; CI-LABEL: @test_atomicrmw_fadd_f64_global_unsafe_strictfp(
1953 ; CI-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1954 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
1955 ; CI: atomicrmw.start:
1956 ; CI-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1957 ; CI-NEXT: [[NEW:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[LOADED]], double [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6]]
1958 ; CI-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1959 ; CI-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1960 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
1961 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1962 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1963 ; CI-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1964 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1965 ; CI: atomicrmw.end:
1966 ; CI-NEXT: ret double [[TMP5]]
1968 ; GFX9-LABEL: @test_atomicrmw_fadd_f64_global_unsafe_strictfp(
1969 ; GFX9-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1970 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
1971 ; GFX9: atomicrmw.start:
1972 ; GFX9-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1973 ; GFX9-NEXT: [[NEW:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[LOADED]], double [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6]]
1974 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1975 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1976 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
1977 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1978 ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1979 ; GFX9-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1980 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1981 ; GFX9: atomicrmw.end:
1982 ; GFX9-NEXT: ret double [[TMP5]]
1984 ; GFX908-LABEL: @test_atomicrmw_fadd_f64_global_unsafe_strictfp(
1985 ; GFX908-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
1986 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
1987 ; GFX908: atomicrmw.start:
1988 ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
1989 ; GFX908-NEXT: [[NEW:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[LOADED]], double [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6:[0-9]+]]
1990 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
1991 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
1992 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
1993 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
1994 ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
1995 ; GFX908-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
1996 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
1997 ; GFX908: atomicrmw.end:
1998 ; GFX908-NEXT: ret double [[TMP5]]
2000 ; GFX90A-LABEL: @test_atomicrmw_fadd_f64_global_unsafe_strictfp(
2001 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], double [[VALUE:%.*]] syncscope("wavefront") monotonic, align 8
2002 ; GFX90A-NEXT: ret double [[RES]]
2004 ; GFX940-LABEL: @test_atomicrmw_fadd_f64_global_unsafe_strictfp(
2005 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(1) [[PTR:%.*]], double [[VALUE:%.*]] syncscope("wavefront") monotonic, align 8
2006 ; GFX940-NEXT: ret double [[RES]]
2008 ; GFX11-LABEL: @test_atomicrmw_fadd_f64_global_unsafe_strictfp(
2009 ; GFX11-NEXT: [[TMP1:%.*]] = load double, ptr addrspace(1) [[PTR:%.*]], align 8
2010 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
2011 ; GFX11: atomicrmw.start:
2012 ; GFX11-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
2013 ; GFX11-NEXT: [[NEW:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[LOADED]], double [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6:[0-9]+]]
2014 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast double [[NEW]] to i64
2015 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast double [[LOADED]] to i64
2016 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i64 [[TMP3]], i64 [[TMP2]] syncscope("wavefront") monotonic monotonic, align 8
2017 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP4]], 1
2018 ; GFX11-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP4]], 0
2019 ; GFX11-NEXT: [[TMP5]] = bitcast i64 [[NEWLOADED]] to double
2020 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2021 ; GFX11: atomicrmw.end:
2022 ; GFX11-NEXT: ret double [[TMP5]]
2024 %res = atomicrmw fadd ptr addrspace(1) %ptr, double %value syncscope("wavefront") monotonic
2028 define float @test_atomicrmw_fadd_f32_local_strictfp(ptr addrspace(3) %ptr, float %value) #2 {
2029 ; CI-LABEL: @test_atomicrmw_fadd_f32_local_strictfp(
2030 ; CI-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(3) [[PTR:%.*]], align 4
2031 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2032 ; CI: atomicrmw.start:
2033 ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP5:%.*]], [[ATOMICRMW_START]] ]
2034 ; CI-NEXT: [[NEW:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[LOADED]], float [[VALUE:%.*]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR6]]
2035 ; CI-NEXT: [[TMP2:%.*]] = bitcast float [[NEW]] to i32
2036 ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[LOADED]] to i32
2037 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[TMP3]], i32 [[TMP2]] seq_cst seq_cst, align 4
2038 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2039 ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP4]], 0
2040 ; CI-NEXT: [[TMP5]] = bitcast i32 [[NEWLOADED]] to float
2041 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2042 ; CI: atomicrmw.end:
2043 ; CI-NEXT: ret float [[TMP5]]
2045 ; GFX9-LABEL: @test_atomicrmw_fadd_f32_local_strictfp(
2046 ; GFX9-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
2047 ; GFX9-NEXT: ret float [[RES]]
2049 ; GFX908-LABEL: @test_atomicrmw_fadd_f32_local_strictfp(
2050 ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
2051 ; GFX908-NEXT: ret float [[RES]]
2053 ; GFX90A-LABEL: @test_atomicrmw_fadd_f32_local_strictfp(
2054 ; GFX90A-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
2055 ; GFX90A-NEXT: ret float [[RES]]
2057 ; GFX940-LABEL: @test_atomicrmw_fadd_f32_local_strictfp(
2058 ; GFX940-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
2059 ; GFX940-NEXT: ret float [[RES]]
2061 ; GFX11-LABEL: @test_atomicrmw_fadd_f32_local_strictfp(
2062 ; GFX11-NEXT: [[RES:%.*]] = atomicrmw fadd ptr addrspace(3) [[PTR:%.*]], float [[VALUE:%.*]] seq_cst, align 4
2063 ; GFX11-NEXT: ret float [[RES]]
2065 %res = atomicrmw fadd ptr addrspace(3) %ptr, float %value seq_cst
2069 define bfloat @test_atomicrmw_fadd_bf16_local(ptr addrspace(3) %ptr, bfloat %value) {
2070 ; CI-LABEL: @test_atomicrmw_fadd_bf16_local(
2071 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
2072 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
2073 ; CI-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
2074 ; CI-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
2075 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
2076 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2077 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
2078 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2079 ; CI: atomicrmw.start:
2080 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2081 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
2082 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2083 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2084 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2085 ; CI-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2086 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2087 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
2088 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2089 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2090 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2091 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2092 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2093 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2094 ; CI: atomicrmw.end:
2095 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
2096 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2097 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2098 ; CI-NEXT: ret bfloat [[TMP7]]
2100 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_local(
2101 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
2102 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
2103 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
2104 ; GFX9-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
2105 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
2106 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2107 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
2108 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
2109 ; GFX9: atomicrmw.start:
2110 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2111 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
2112 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2113 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2114 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2115 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2116 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2117 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
2118 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2119 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2120 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2121 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2122 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2123 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2124 ; GFX9: atomicrmw.end:
2125 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
2126 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2127 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2128 ; GFX9-NEXT: ret bfloat [[TMP7]]
2130 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_local(
2131 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
2132 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
2133 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
2134 ; GFX908-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
2135 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
2136 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2137 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
2138 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
2139 ; GFX908: atomicrmw.start:
2140 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2141 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
2142 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2143 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2144 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2145 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2146 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2147 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
2148 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2149 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2150 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2151 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2152 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2153 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2154 ; GFX908: atomicrmw.end:
2155 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
2156 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2157 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2158 ; GFX908-NEXT: ret bfloat [[TMP7]]
2160 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_local(
2161 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
2162 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
2163 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
2164 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
2165 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
2166 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2167 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
2168 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
2169 ; GFX90A: atomicrmw.start:
2170 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2171 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
2172 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2173 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2174 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2175 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2176 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2177 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
2178 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2179 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2180 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2181 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2182 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2183 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2184 ; GFX90A: atomicrmw.end:
2185 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
2186 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2187 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2188 ; GFX90A-NEXT: ret bfloat [[TMP7]]
2190 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_local(
2191 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
2192 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
2193 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
2194 ; GFX940-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
2195 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
2196 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2197 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
2198 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
2199 ; GFX940: atomicrmw.start:
2200 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2201 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
2202 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2203 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2204 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2205 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2206 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2207 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
2208 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2209 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2210 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2211 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2212 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2213 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2214 ; GFX940: atomicrmw.end:
2215 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
2216 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2217 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2218 ; GFX940-NEXT: ret bfloat [[TMP7]]
2220 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_local(
2221 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
2222 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
2223 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
2224 ; GFX11-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
2225 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
2226 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2227 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
2228 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
2229 ; GFX11: atomicrmw.start:
2230 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2231 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
2232 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2233 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2234 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2235 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2236 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2237 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
2238 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2239 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2240 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2241 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2242 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2243 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2244 ; GFX11: atomicrmw.end:
2245 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
2246 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2247 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2248 ; GFX11-NEXT: ret bfloat [[TMP7]]
2250 %res = atomicrmw fadd ptr addrspace(3) %ptr, bfloat %value monotonic
2254 define bfloat @test_atomicrmw_fadd_bf16_local_align4(ptr addrspace(3) %ptr, bfloat %value) {
2255 ; CI-LABEL: @test_atomicrmw_fadd_bf16_local_align4(
2256 ; CI-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[PTR:%.*]], align 4
2257 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2258 ; CI: atomicrmw.start:
2259 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2260 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2261 ; CI-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2262 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2263 ; CI-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2264 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2265 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2266 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2267 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2268 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2269 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2270 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2271 ; CI: atomicrmw.end:
2272 ; CI-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2273 ; CI-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2274 ; CI-NEXT: ret bfloat [[TMP5]]
2276 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_local_align4(
2277 ; GFX9-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[PTR:%.*]], align 4
2278 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
2279 ; GFX9: atomicrmw.start:
2280 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2281 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2282 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2283 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2284 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2285 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2286 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2287 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2288 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2289 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2290 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2291 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2292 ; GFX9: atomicrmw.end:
2293 ; GFX9-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2294 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2295 ; GFX9-NEXT: ret bfloat [[TMP5]]
2297 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_local_align4(
2298 ; GFX908-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[PTR:%.*]], align 4
2299 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
2300 ; GFX908: atomicrmw.start:
2301 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2302 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2303 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2304 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2305 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2306 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2307 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2308 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2309 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2310 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2311 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2312 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2313 ; GFX908: atomicrmw.end:
2314 ; GFX908-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2315 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2316 ; GFX908-NEXT: ret bfloat [[TMP5]]
2318 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_local_align4(
2319 ; GFX90A-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[PTR:%.*]], align 4
2320 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
2321 ; GFX90A: atomicrmw.start:
2322 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2323 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2324 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2325 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2326 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2327 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2328 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2329 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2330 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2331 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2332 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2333 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2334 ; GFX90A: atomicrmw.end:
2335 ; GFX90A-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2336 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2337 ; GFX90A-NEXT: ret bfloat [[TMP5]]
2339 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_local_align4(
2340 ; GFX940-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[PTR:%.*]], align 4
2341 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
2342 ; GFX940: atomicrmw.start:
2343 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2344 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2345 ; GFX940-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2346 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2347 ; GFX940-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2348 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2349 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2350 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2351 ; GFX940-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2352 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2353 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2354 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2355 ; GFX940: atomicrmw.end:
2356 ; GFX940-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2357 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2358 ; GFX940-NEXT: ret bfloat [[TMP5]]
2360 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_local_align4(
2361 ; GFX11-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(3) [[PTR:%.*]], align 4
2362 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
2363 ; GFX11: atomicrmw.start:
2364 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2365 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2366 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2367 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2368 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2369 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2370 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2371 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2372 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(3) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2373 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2374 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2375 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2376 ; GFX11: atomicrmw.end:
2377 ; GFX11-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2378 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2379 ; GFX11-NEXT: ret bfloat [[TMP5]]
2381 %res = atomicrmw fadd ptr addrspace(3) %ptr, bfloat %value monotonic, align 4
2385 define bfloat @test_atomicrmw_fadd_bf16_global_agent(ptr addrspace(1) %ptr, bfloat %value) {
2386 ; CI-LABEL: @test_atomicrmw_fadd_bf16_global_agent(
2387 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2388 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2389 ; CI-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2390 ; CI-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2391 ; CI-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2392 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2393 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2394 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2395 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2396 ; CI: atomicrmw.start:
2397 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2398 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2399 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2400 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2401 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2402 ; CI-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2403 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2404 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2405 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2406 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2407 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2408 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2409 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2410 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2411 ; CI: atomicrmw.end:
2412 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2413 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2414 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2415 ; CI-NEXT: ret bfloat [[TMP7]]
2417 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_global_agent(
2418 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2419 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2420 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2421 ; GFX9-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2422 ; GFX9-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2423 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2424 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2425 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2426 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
2427 ; GFX9: atomicrmw.start:
2428 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2429 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2430 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2431 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2432 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2433 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2434 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2435 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2436 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2437 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2438 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2439 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2440 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2441 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2442 ; GFX9: atomicrmw.end:
2443 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2444 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2445 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2446 ; GFX9-NEXT: ret bfloat [[TMP7]]
2448 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_global_agent(
2449 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2450 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2451 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2452 ; GFX908-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2453 ; GFX908-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2454 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2455 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2456 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2457 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
2458 ; GFX908: atomicrmw.start:
2459 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2460 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2461 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2462 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2463 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2464 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2465 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2466 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2467 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2468 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2469 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2470 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2471 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2472 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2473 ; GFX908: atomicrmw.end:
2474 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2475 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2476 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2477 ; GFX908-NEXT: ret bfloat [[TMP7]]
2479 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_global_agent(
2480 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2481 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2482 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2483 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2484 ; GFX90A-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2485 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2486 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2487 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2488 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
2489 ; GFX90A: atomicrmw.start:
2490 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2491 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2492 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2493 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2494 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2495 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2496 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2497 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2498 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2499 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2500 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2501 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2502 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2503 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2504 ; GFX90A: atomicrmw.end:
2505 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2506 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2507 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2508 ; GFX90A-NEXT: ret bfloat [[TMP7]]
2510 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_global_agent(
2511 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2512 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2513 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2514 ; GFX940-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2515 ; GFX940-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2516 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2517 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2518 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2519 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
2520 ; GFX940: atomicrmw.start:
2521 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2522 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2523 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2524 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2525 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2526 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2527 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2528 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2529 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2530 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2531 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2532 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2533 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2534 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2535 ; GFX940: atomicrmw.end:
2536 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2537 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2538 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2539 ; GFX940-NEXT: ret bfloat [[TMP7]]
2541 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_global_agent(
2542 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2543 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2544 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2545 ; GFX11-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2546 ; GFX11-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2547 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2548 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2549 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2550 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
2551 ; GFX11: atomicrmw.start:
2552 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2553 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2554 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2555 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2556 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2557 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2558 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2559 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2560 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2561 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2562 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2563 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2564 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2565 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2566 ; GFX11: atomicrmw.end:
2567 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2568 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2569 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2570 ; GFX11-NEXT: ret bfloat [[TMP7]]
2572 %res = atomicrmw fadd ptr addrspace(1) %ptr, bfloat %value syncscope("agent") monotonic
2576 define bfloat @test_atomicrmw_fadd_bf16_global_agent_align4(ptr addrspace(1) %ptr, bfloat %value) {
2577 ; CI-LABEL: @test_atomicrmw_fadd_bf16_global_agent_align4(
2578 ; CI-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2579 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2580 ; CI: atomicrmw.start:
2581 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2582 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2583 ; CI-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2584 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2585 ; CI-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2586 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2587 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2588 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2589 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2590 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2591 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2592 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2593 ; CI: atomicrmw.end:
2594 ; CI-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2595 ; CI-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2596 ; CI-NEXT: ret bfloat [[TMP5]]
2598 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_global_agent_align4(
2599 ; GFX9-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2600 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
2601 ; GFX9: atomicrmw.start:
2602 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2603 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2604 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2605 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2606 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2607 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2608 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2609 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2610 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2611 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2612 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2613 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2614 ; GFX9: atomicrmw.end:
2615 ; GFX9-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2616 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2617 ; GFX9-NEXT: ret bfloat [[TMP5]]
2619 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_global_agent_align4(
2620 ; GFX908-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2621 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
2622 ; GFX908: atomicrmw.start:
2623 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2624 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2625 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2626 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2627 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2628 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2629 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2630 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2631 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2632 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2633 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2634 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2635 ; GFX908: atomicrmw.end:
2636 ; GFX908-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2637 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2638 ; GFX908-NEXT: ret bfloat [[TMP5]]
2640 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_global_agent_align4(
2641 ; GFX90A-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2642 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
2643 ; GFX90A: atomicrmw.start:
2644 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2645 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2646 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2647 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2648 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2649 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2650 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2651 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2652 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2653 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2654 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2655 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2656 ; GFX90A: atomicrmw.end:
2657 ; GFX90A-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2658 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2659 ; GFX90A-NEXT: ret bfloat [[TMP5]]
2661 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_global_agent_align4(
2662 ; GFX940-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2663 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
2664 ; GFX940: atomicrmw.start:
2665 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2666 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2667 ; GFX940-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2668 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2669 ; GFX940-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2670 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2671 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2672 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2673 ; GFX940-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2674 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2675 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2676 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2677 ; GFX940: atomicrmw.end:
2678 ; GFX940-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2679 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2680 ; GFX940-NEXT: ret bfloat [[TMP5]]
2682 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_global_agent_align4(
2683 ; GFX11-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2684 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
2685 ; GFX11: atomicrmw.start:
2686 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2687 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2688 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2689 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2690 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2691 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2692 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2693 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2694 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
2695 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2696 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2697 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2698 ; GFX11: atomicrmw.end:
2699 ; GFX11-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2700 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2701 ; GFX11-NEXT: ret bfloat [[TMP5]]
2703 %res = atomicrmw fadd ptr addrspace(1) %ptr, bfloat %value syncscope("agent") monotonic, align 4
2707 define bfloat @test_atomicrmw_fadd_bf16_global_system(ptr addrspace(1) %ptr, bfloat %value) {
2708 ; CI-LABEL: @test_atomicrmw_fadd_bf16_global_system(
2709 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2710 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2711 ; CI-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2712 ; CI-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2713 ; CI-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2714 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2715 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2716 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2717 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2718 ; CI: atomicrmw.start:
2719 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2720 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2721 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2722 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2723 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2724 ; CI-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2725 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2726 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2727 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2728 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2729 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2730 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2731 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2732 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2733 ; CI: atomicrmw.end:
2734 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2735 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2736 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2737 ; CI-NEXT: ret bfloat [[TMP7]]
2739 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_global_system(
2740 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2741 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2742 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2743 ; GFX9-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2744 ; GFX9-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2745 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2746 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2747 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2748 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
2749 ; GFX9: atomicrmw.start:
2750 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2751 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2752 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2753 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2754 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2755 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2756 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2757 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2758 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2759 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2760 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2761 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2762 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2763 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2764 ; GFX9: atomicrmw.end:
2765 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2766 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2767 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2768 ; GFX9-NEXT: ret bfloat [[TMP7]]
2770 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_global_system(
2771 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2772 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2773 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2774 ; GFX908-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2775 ; GFX908-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2776 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2777 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2778 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2779 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
2780 ; GFX908: atomicrmw.start:
2781 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2782 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2783 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2784 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2785 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2786 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2787 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2788 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2789 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2790 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2791 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2792 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2793 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2794 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2795 ; GFX908: atomicrmw.end:
2796 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2797 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2798 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2799 ; GFX908-NEXT: ret bfloat [[TMP7]]
2801 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_global_system(
2802 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2803 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2804 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2805 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2806 ; GFX90A-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2807 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2808 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2809 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2810 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
2811 ; GFX90A: atomicrmw.start:
2812 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2813 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2814 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2815 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2816 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2817 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2818 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2819 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2820 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2821 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2822 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2823 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2824 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2825 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2826 ; GFX90A: atomicrmw.end:
2827 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2828 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2829 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2830 ; GFX90A-NEXT: ret bfloat [[TMP7]]
2832 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_global_system(
2833 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2834 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2835 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2836 ; GFX940-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2837 ; GFX940-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2838 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2839 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2840 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2841 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
2842 ; GFX940: atomicrmw.start:
2843 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2844 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2845 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2846 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2847 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2848 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2849 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2850 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2851 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2852 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2853 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2854 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2855 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2856 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2857 ; GFX940: atomicrmw.end:
2858 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2859 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2860 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2861 ; GFX940-NEXT: ret bfloat [[TMP7]]
2863 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_global_system(
2864 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(1) @llvm.ptrmask.p1.i64(ptr addrspace(1) [[PTR:%.*]], i64 -4)
2865 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(1) [[PTR]] to i64
2866 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
2867 ; GFX11-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
2868 ; GFX11-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
2869 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
2870 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
2871 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(1) [[ALIGNEDADDR]], align 4
2872 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
2873 ; GFX11: atomicrmw.start:
2874 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2875 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
2876 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
2877 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2878 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
2879 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
2880 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
2881 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
2882 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
2883 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
2884 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(1) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2885 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
2886 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
2887 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2888 ; GFX11: atomicrmw.end:
2889 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
2890 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
2891 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
2892 ; GFX11-NEXT: ret bfloat [[TMP7]]
2894 %res = atomicrmw fadd ptr addrspace(1) %ptr, bfloat %value monotonic
2898 define bfloat @test_atomicrmw_fadd_bf16_global_system_align4(ptr addrspace(1) %ptr, bfloat %value) {
2899 ; CI-LABEL: @test_atomicrmw_fadd_bf16_global_system_align4(
2900 ; CI-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2901 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
2902 ; CI: atomicrmw.start:
2903 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2904 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2905 ; CI-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2906 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2907 ; CI-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2908 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2909 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2910 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2911 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2912 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2913 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2914 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2915 ; CI: atomicrmw.end:
2916 ; CI-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2917 ; CI-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2918 ; CI-NEXT: ret bfloat [[TMP5]]
2920 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_global_system_align4(
2921 ; GFX9-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2922 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
2923 ; GFX9: atomicrmw.start:
2924 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2925 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2926 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2927 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2928 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2929 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2930 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2931 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2932 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2933 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2934 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2935 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2936 ; GFX9: atomicrmw.end:
2937 ; GFX9-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2938 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2939 ; GFX9-NEXT: ret bfloat [[TMP5]]
2941 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_global_system_align4(
2942 ; GFX908-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2943 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
2944 ; GFX908: atomicrmw.start:
2945 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2946 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2947 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2948 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2949 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2950 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2951 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2952 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2953 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2954 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2955 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2956 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2957 ; GFX908: atomicrmw.end:
2958 ; GFX908-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2959 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2960 ; GFX908-NEXT: ret bfloat [[TMP5]]
2962 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_global_system_align4(
2963 ; GFX90A-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2964 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
2965 ; GFX90A: atomicrmw.start:
2966 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2967 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2968 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2969 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2970 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2971 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2972 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2973 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2974 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2975 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2976 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2977 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2978 ; GFX90A: atomicrmw.end:
2979 ; GFX90A-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
2980 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
2981 ; GFX90A-NEXT: ret bfloat [[TMP5]]
2983 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_global_system_align4(
2984 ; GFX940-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
2985 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
2986 ; GFX940: atomicrmw.start:
2987 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
2988 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
2989 ; GFX940-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
2990 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
2991 ; GFX940-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
2992 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
2993 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
2994 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
2995 ; GFX940-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
2996 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
2997 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
2998 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
2999 ; GFX940: atomicrmw.end:
3000 ; GFX940-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3001 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3002 ; GFX940-NEXT: ret bfloat [[TMP5]]
3004 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_global_system_align4(
3005 ; GFX11-NEXT: [[TMP1:%.*]] = load i32, ptr addrspace(1) [[PTR:%.*]], align 4
3006 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
3007 ; GFX11: atomicrmw.start:
3008 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3009 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3010 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3011 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3012 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3013 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3014 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3015 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3016 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr addrspace(1) [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3017 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3018 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3019 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3020 ; GFX11: atomicrmw.end:
3021 ; GFX11-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3022 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3023 ; GFX11-NEXT: ret bfloat [[TMP5]]
3025 %res = atomicrmw fadd ptr addrspace(1) %ptr, bfloat %value monotonic, align 4
3029 define bfloat @test_atomicrmw_fadd_bf16_local_strictfp(ptr addrspace(3) %ptr, bfloat %value) #2 {
3030 ; CI-LABEL: @test_atomicrmw_fadd_bf16_local_strictfp(
3031 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
3032 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
3033 ; CI-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
3034 ; CI-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
3035 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
3036 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3037 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
3038 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
3039 ; CI: atomicrmw.start:
3040 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3041 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
3042 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3043 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3044 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3045 ; CI-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3046 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3047 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
3048 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3049 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3050 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3051 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3052 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3053 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3054 ; CI: atomicrmw.end:
3055 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
3056 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3057 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3058 ; CI-NEXT: ret bfloat [[TMP7]]
3060 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_local_strictfp(
3061 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
3062 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
3063 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
3064 ; GFX9-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
3065 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
3066 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3067 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
3068 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
3069 ; GFX9: atomicrmw.start:
3070 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3071 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
3072 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3073 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3074 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3075 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3076 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3077 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
3078 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3079 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3080 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3081 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3082 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3083 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3084 ; GFX9: atomicrmw.end:
3085 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
3086 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3087 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3088 ; GFX9-NEXT: ret bfloat [[TMP7]]
3090 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_local_strictfp(
3091 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
3092 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
3093 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
3094 ; GFX908-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
3095 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
3096 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3097 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
3098 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
3099 ; GFX908: atomicrmw.start:
3100 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3101 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
3102 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3103 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3104 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3105 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3106 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3107 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
3108 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3109 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3110 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3111 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3112 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3113 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3114 ; GFX908: atomicrmw.end:
3115 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
3116 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3117 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3118 ; GFX908-NEXT: ret bfloat [[TMP7]]
3120 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_local_strictfp(
3121 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
3122 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
3123 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
3124 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
3125 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
3126 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3127 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
3128 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
3129 ; GFX90A: atomicrmw.start:
3130 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3131 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
3132 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3133 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3134 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3135 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3136 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3137 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
3138 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3139 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3140 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3141 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3142 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3143 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3144 ; GFX90A: atomicrmw.end:
3145 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
3146 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3147 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3148 ; GFX90A-NEXT: ret bfloat [[TMP7]]
3150 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_local_strictfp(
3151 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
3152 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
3153 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
3154 ; GFX940-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
3155 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
3156 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3157 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
3158 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
3159 ; GFX940: atomicrmw.start:
3160 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3161 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
3162 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3163 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3164 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3165 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3166 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3167 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
3168 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3169 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3170 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3171 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3172 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3173 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3174 ; GFX940: atomicrmw.end:
3175 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
3176 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3177 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3178 ; GFX940-NEXT: ret bfloat [[TMP7]]
3180 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_local_strictfp(
3181 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr addrspace(3) @llvm.ptrmask.p3.i32(ptr addrspace(3) [[PTR:%.*]], i32 -4)
3182 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr addrspace(3) [[PTR]] to i32
3183 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i32 [[TMP1]], 3
3184 ; GFX11-NEXT: [[TMP2:%.*]] = shl i32 [[PTRLSB]], 3
3185 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[TMP2]]
3186 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3187 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr addrspace(3) [[ALIGNEDADDR]], align 4
3188 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
3189 ; GFX11: atomicrmw.start:
3190 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3191 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[TMP2]]
3192 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3193 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3194 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3195 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3196 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3197 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[TMP2]]
3198 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3199 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3200 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr addrspace(3) [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3201 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3202 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3203 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3204 ; GFX11: atomicrmw.end:
3205 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[TMP2]]
3206 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3207 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3208 ; GFX11-NEXT: ret bfloat [[TMP7]]
3210 %res = atomicrmw fadd ptr addrspace(3) %ptr, bfloat %value monotonic
3214 define bfloat @test_atomicrmw_fadd_bf16_flat_agent(ptr %ptr, bfloat %value) {
3215 ; CI-LABEL: @test_atomicrmw_fadd_bf16_flat_agent(
3216 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3217 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3218 ; CI-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3219 ; CI-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3220 ; CI-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3221 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3222 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3223 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3224 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
3225 ; CI: atomicrmw.start:
3226 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3227 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3228 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3229 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3230 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3231 ; CI-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3232 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3233 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3234 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3235 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3236 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3237 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3238 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3239 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3240 ; CI: atomicrmw.end:
3241 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3242 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3243 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3244 ; CI-NEXT: ret bfloat [[TMP7]]
3246 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_flat_agent(
3247 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3248 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3249 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3250 ; GFX9-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3251 ; GFX9-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3252 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3253 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3254 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3255 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
3256 ; GFX9: atomicrmw.start:
3257 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3258 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3259 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3260 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3261 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3262 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3263 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3264 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3265 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3266 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3267 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3268 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3269 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3270 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3271 ; GFX9: atomicrmw.end:
3272 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3273 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3274 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3275 ; GFX9-NEXT: ret bfloat [[TMP7]]
3277 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_flat_agent(
3278 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3279 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3280 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3281 ; GFX908-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3282 ; GFX908-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3283 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3284 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3285 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3286 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
3287 ; GFX908: atomicrmw.start:
3288 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3289 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3290 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3291 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3292 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3293 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3294 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3295 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3296 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3297 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3298 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3299 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3300 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3301 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3302 ; GFX908: atomicrmw.end:
3303 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3304 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3305 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3306 ; GFX908-NEXT: ret bfloat [[TMP7]]
3308 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_flat_agent(
3309 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3310 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3311 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3312 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3313 ; GFX90A-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3314 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3315 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3316 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3317 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
3318 ; GFX90A: atomicrmw.start:
3319 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3320 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3321 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3322 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3323 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3324 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3325 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3326 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3327 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3328 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3329 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3330 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3331 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3332 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3333 ; GFX90A: atomicrmw.end:
3334 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3335 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3336 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3337 ; GFX90A-NEXT: ret bfloat [[TMP7]]
3339 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_flat_agent(
3340 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3341 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3342 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3343 ; GFX940-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3344 ; GFX940-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3345 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3346 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3347 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3348 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
3349 ; GFX940: atomicrmw.start:
3350 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3351 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3352 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3353 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3354 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3355 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3356 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3357 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3358 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3359 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3360 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3361 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3362 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3363 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3364 ; GFX940: atomicrmw.end:
3365 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3366 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3367 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3368 ; GFX940-NEXT: ret bfloat [[TMP7]]
3370 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_flat_agent(
3371 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3372 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3373 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3374 ; GFX11-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3375 ; GFX11-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3376 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3377 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3378 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3379 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
3380 ; GFX11: atomicrmw.start:
3381 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3382 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3383 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3384 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3385 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3386 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3387 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3388 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3389 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3390 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3391 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3392 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3393 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3394 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3395 ; GFX11: atomicrmw.end:
3396 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3397 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3398 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3399 ; GFX11-NEXT: ret bfloat [[TMP7]]
3401 %res = atomicrmw fadd ptr %ptr, bfloat %value syncscope("agent") monotonic
3405 define bfloat @test_atomicrmw_fadd_bf16_flat_agent_align4(ptr %ptr, bfloat %value) {
3406 ; CI-LABEL: @test_atomicrmw_fadd_bf16_flat_agent_align4(
3407 ; CI-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3408 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
3409 ; CI: atomicrmw.start:
3410 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3411 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3412 ; CI-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3413 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3414 ; CI-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3415 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3416 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3417 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3418 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3419 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3420 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3421 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3422 ; CI: atomicrmw.end:
3423 ; CI-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3424 ; CI-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3425 ; CI-NEXT: ret bfloat [[TMP5]]
3427 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_flat_agent_align4(
3428 ; GFX9-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3429 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
3430 ; GFX9: atomicrmw.start:
3431 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3432 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3433 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3434 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3435 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3436 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3437 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3438 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3439 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3440 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3441 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3442 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3443 ; GFX9: atomicrmw.end:
3444 ; GFX9-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3445 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3446 ; GFX9-NEXT: ret bfloat [[TMP5]]
3448 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_flat_agent_align4(
3449 ; GFX908-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3450 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
3451 ; GFX908: atomicrmw.start:
3452 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3453 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3454 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3455 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3456 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3457 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3458 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3459 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3460 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3461 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3462 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3463 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3464 ; GFX908: atomicrmw.end:
3465 ; GFX908-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3466 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3467 ; GFX908-NEXT: ret bfloat [[TMP5]]
3469 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_flat_agent_align4(
3470 ; GFX90A-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3471 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
3472 ; GFX90A: atomicrmw.start:
3473 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3474 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3475 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3476 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3477 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3478 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3479 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3480 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3481 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3482 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3483 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3484 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3485 ; GFX90A: atomicrmw.end:
3486 ; GFX90A-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3487 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3488 ; GFX90A-NEXT: ret bfloat [[TMP5]]
3490 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_flat_agent_align4(
3491 ; GFX940-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3492 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
3493 ; GFX940: atomicrmw.start:
3494 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3495 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3496 ; GFX940-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3497 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3498 ; GFX940-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3499 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3500 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3501 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3502 ; GFX940-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3503 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3504 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3505 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3506 ; GFX940: atomicrmw.end:
3507 ; GFX940-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3508 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3509 ; GFX940-NEXT: ret bfloat [[TMP5]]
3511 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_flat_agent_align4(
3512 ; GFX11-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3513 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
3514 ; GFX11: atomicrmw.start:
3515 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3516 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3517 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3518 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3519 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3520 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3521 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3522 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3523 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] syncscope("agent") monotonic monotonic, align 4
3524 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3525 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3526 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3527 ; GFX11: atomicrmw.end:
3528 ; GFX11-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3529 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3530 ; GFX11-NEXT: ret bfloat [[TMP5]]
3532 %res = atomicrmw fadd ptr %ptr, bfloat %value syncscope("agent") monotonic, align 4
3536 define bfloat @test_atomicrmw_fadd_bf16_flat_system(ptr %ptr, bfloat %value) {
3537 ; CI-LABEL: @test_atomicrmw_fadd_bf16_flat_system(
3538 ; CI-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3539 ; CI-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3540 ; CI-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3541 ; CI-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3542 ; CI-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3543 ; CI-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3544 ; CI-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3545 ; CI-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3546 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
3547 ; CI: atomicrmw.start:
3548 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3549 ; CI-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3550 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3551 ; CI-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3552 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3553 ; CI-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3554 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3555 ; CI-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3556 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3557 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3558 ; CI-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3559 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3560 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3561 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3562 ; CI: atomicrmw.end:
3563 ; CI-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3564 ; CI-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3565 ; CI-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3566 ; CI-NEXT: ret bfloat [[TMP7]]
3568 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_flat_system(
3569 ; GFX9-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3570 ; GFX9-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3571 ; GFX9-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3572 ; GFX9-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3573 ; GFX9-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3574 ; GFX9-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3575 ; GFX9-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3576 ; GFX9-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3577 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
3578 ; GFX9: atomicrmw.start:
3579 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3580 ; GFX9-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3581 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3582 ; GFX9-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3583 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3584 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3585 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3586 ; GFX9-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3587 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3588 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3589 ; GFX9-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3590 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3591 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3592 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3593 ; GFX9: atomicrmw.end:
3594 ; GFX9-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3595 ; GFX9-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3596 ; GFX9-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3597 ; GFX9-NEXT: ret bfloat [[TMP7]]
3599 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_flat_system(
3600 ; GFX908-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3601 ; GFX908-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3602 ; GFX908-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3603 ; GFX908-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3604 ; GFX908-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3605 ; GFX908-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3606 ; GFX908-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3607 ; GFX908-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3608 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
3609 ; GFX908: atomicrmw.start:
3610 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3611 ; GFX908-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3612 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3613 ; GFX908-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3614 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3615 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3616 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3617 ; GFX908-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3618 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3619 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3620 ; GFX908-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3621 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3622 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3623 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3624 ; GFX908: atomicrmw.end:
3625 ; GFX908-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3626 ; GFX908-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3627 ; GFX908-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3628 ; GFX908-NEXT: ret bfloat [[TMP7]]
3630 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_flat_system(
3631 ; GFX90A-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3632 ; GFX90A-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3633 ; GFX90A-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3634 ; GFX90A-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3635 ; GFX90A-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3636 ; GFX90A-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3637 ; GFX90A-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3638 ; GFX90A-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3639 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
3640 ; GFX90A: atomicrmw.start:
3641 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3642 ; GFX90A-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3643 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3644 ; GFX90A-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3645 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3646 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3647 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3648 ; GFX90A-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3649 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3650 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3651 ; GFX90A-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3652 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3653 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3654 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3655 ; GFX90A: atomicrmw.end:
3656 ; GFX90A-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3657 ; GFX90A-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3658 ; GFX90A-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3659 ; GFX90A-NEXT: ret bfloat [[TMP7]]
3661 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_flat_system(
3662 ; GFX940-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3663 ; GFX940-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3664 ; GFX940-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3665 ; GFX940-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3666 ; GFX940-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3667 ; GFX940-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3668 ; GFX940-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3669 ; GFX940-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3670 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
3671 ; GFX940: atomicrmw.start:
3672 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3673 ; GFX940-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3674 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3675 ; GFX940-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3676 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3677 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3678 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3679 ; GFX940-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3680 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3681 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3682 ; GFX940-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3683 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3684 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3685 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3686 ; GFX940: atomicrmw.end:
3687 ; GFX940-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3688 ; GFX940-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3689 ; GFX940-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3690 ; GFX940-NEXT: ret bfloat [[TMP7]]
3692 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_flat_system(
3693 ; GFX11-NEXT: [[ALIGNEDADDR:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[PTR:%.*]], i64 -4)
3694 ; GFX11-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
3695 ; GFX11-NEXT: [[PTRLSB:%.*]] = and i64 [[TMP1]], 3
3696 ; GFX11-NEXT: [[TMP2:%.*]] = shl i64 [[PTRLSB]], 3
3697 ; GFX11-NEXT: [[SHIFTAMT:%.*]] = trunc i64 [[TMP2]] to i32
3698 ; GFX11-NEXT: [[MASK:%.*]] = shl i32 65535, [[SHIFTAMT]]
3699 ; GFX11-NEXT: [[INV_MASK:%.*]] = xor i32 [[MASK]], -1
3700 ; GFX11-NEXT: [[TMP3:%.*]] = load i32, ptr [[ALIGNEDADDR]], align 4
3701 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
3702 ; GFX11: atomicrmw.start:
3703 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP3]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3704 ; GFX11-NEXT: [[SHIFTED:%.*]] = lshr i32 [[LOADED]], [[SHIFTAMT]]
3705 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[SHIFTED]] to i16
3706 ; GFX11-NEXT: [[TMP4:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3707 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP4]], [[VALUE:%.*]]
3708 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast bfloat [[NEW]] to i16
3709 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP5]] to i32
3710 ; GFX11-NEXT: [[SHIFTED1:%.*]] = shl nuw i32 [[EXTENDED]], [[SHIFTAMT]]
3711 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], [[INV_MASK]]
3712 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[SHIFTED1]]
3713 ; GFX11-NEXT: [[TMP6:%.*]] = cmpxchg ptr [[ALIGNEDADDR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3714 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1
3715 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP6]], 0
3716 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3717 ; GFX11: atomicrmw.end:
3718 ; GFX11-NEXT: [[SHIFTED2:%.*]] = lshr i32 [[NEWLOADED]], [[SHIFTAMT]]
3719 ; GFX11-NEXT: [[EXTRACTED3:%.*]] = trunc i32 [[SHIFTED2]] to i16
3720 ; GFX11-NEXT: [[TMP7:%.*]] = bitcast i16 [[EXTRACTED3]] to bfloat
3721 ; GFX11-NEXT: ret bfloat [[TMP7]]
3723 %res = atomicrmw fadd ptr %ptr, bfloat %value monotonic
3727 define bfloat @test_atomicrmw_fadd_bf16_flat_system_align4(ptr %ptr, bfloat %value) {
3728 ; CI-LABEL: @test_atomicrmw_fadd_bf16_flat_system_align4(
3729 ; CI-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3730 ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
3731 ; CI: atomicrmw.start:
3732 ; CI-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3733 ; CI-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3734 ; CI-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3735 ; CI-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3736 ; CI-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3737 ; CI-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3738 ; CI-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3739 ; CI-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3740 ; CI-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3741 ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3742 ; CI-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3743 ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3744 ; CI: atomicrmw.end:
3745 ; CI-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3746 ; CI-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3747 ; CI-NEXT: ret bfloat [[TMP5]]
3749 ; GFX9-LABEL: @test_atomicrmw_fadd_bf16_flat_system_align4(
3750 ; GFX9-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3751 ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
3752 ; GFX9: atomicrmw.start:
3753 ; GFX9-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3754 ; GFX9-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3755 ; GFX9-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3756 ; GFX9-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3757 ; GFX9-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3758 ; GFX9-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3759 ; GFX9-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3760 ; GFX9-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3761 ; GFX9-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3762 ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3763 ; GFX9-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3764 ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3765 ; GFX9: atomicrmw.end:
3766 ; GFX9-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3767 ; GFX9-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3768 ; GFX9-NEXT: ret bfloat [[TMP5]]
3770 ; GFX908-LABEL: @test_atomicrmw_fadd_bf16_flat_system_align4(
3771 ; GFX908-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3772 ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
3773 ; GFX908: atomicrmw.start:
3774 ; GFX908-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3775 ; GFX908-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3776 ; GFX908-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3777 ; GFX908-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3778 ; GFX908-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3779 ; GFX908-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3780 ; GFX908-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3781 ; GFX908-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3782 ; GFX908-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3783 ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3784 ; GFX908-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3785 ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3786 ; GFX908: atomicrmw.end:
3787 ; GFX908-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3788 ; GFX908-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3789 ; GFX908-NEXT: ret bfloat [[TMP5]]
3791 ; GFX90A-LABEL: @test_atomicrmw_fadd_bf16_flat_system_align4(
3792 ; GFX90A-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3793 ; GFX90A-NEXT: br label [[ATOMICRMW_START:%.*]]
3794 ; GFX90A: atomicrmw.start:
3795 ; GFX90A-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3796 ; GFX90A-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3797 ; GFX90A-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3798 ; GFX90A-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3799 ; GFX90A-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3800 ; GFX90A-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3801 ; GFX90A-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3802 ; GFX90A-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3803 ; GFX90A-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3804 ; GFX90A-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3805 ; GFX90A-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3806 ; GFX90A-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3807 ; GFX90A: atomicrmw.end:
3808 ; GFX90A-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3809 ; GFX90A-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3810 ; GFX90A-NEXT: ret bfloat [[TMP5]]
3812 ; GFX940-LABEL: @test_atomicrmw_fadd_bf16_flat_system_align4(
3813 ; GFX940-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3814 ; GFX940-NEXT: br label [[ATOMICRMW_START:%.*]]
3815 ; GFX940: atomicrmw.start:
3816 ; GFX940-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3817 ; GFX940-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3818 ; GFX940-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3819 ; GFX940-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3820 ; GFX940-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3821 ; GFX940-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3822 ; GFX940-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3823 ; GFX940-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3824 ; GFX940-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3825 ; GFX940-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3826 ; GFX940-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3827 ; GFX940-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3828 ; GFX940: atomicrmw.end:
3829 ; GFX940-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3830 ; GFX940-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3831 ; GFX940-NEXT: ret bfloat [[TMP5]]
3833 ; GFX11-LABEL: @test_atomicrmw_fadd_bf16_flat_system_align4(
3834 ; GFX11-NEXT: [[TMP1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
3835 ; GFX11-NEXT: br label [[ATOMICRMW_START:%.*]]
3836 ; GFX11: atomicrmw.start:
3837 ; GFX11-NEXT: [[LOADED:%.*]] = phi i32 [ [[TMP1]], [[TMP0:%.*]] ], [ [[NEWLOADED:%.*]], [[ATOMICRMW_START]] ]
3838 ; GFX11-NEXT: [[EXTRACTED:%.*]] = trunc i32 [[LOADED]] to i16
3839 ; GFX11-NEXT: [[TMP2:%.*]] = bitcast i16 [[EXTRACTED]] to bfloat
3840 ; GFX11-NEXT: [[NEW:%.*]] = fadd bfloat [[TMP2]], [[VALUE:%.*]]
3841 ; GFX11-NEXT: [[TMP3:%.*]] = bitcast bfloat [[NEW]] to i16
3842 ; GFX11-NEXT: [[EXTENDED:%.*]] = zext i16 [[TMP3]] to i32
3843 ; GFX11-NEXT: [[UNMASKED:%.*]] = and i32 [[LOADED]], -65536
3844 ; GFX11-NEXT: [[INSERTED:%.*]] = or i32 [[UNMASKED]], [[EXTENDED]]
3845 ; GFX11-NEXT: [[TMP4:%.*]] = cmpxchg ptr [[PTR]], i32 [[LOADED]], i32 [[INSERTED]] monotonic monotonic, align 4
3846 ; GFX11-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP4]], 1
3847 ; GFX11-NEXT: [[NEWLOADED]] = extractvalue { i32, i1 } [[TMP4]], 0
3848 ; GFX11-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
3849 ; GFX11: atomicrmw.end:
3850 ; GFX11-NEXT: [[EXTRACTED1:%.*]] = trunc i32 [[NEWLOADED]] to i16
3851 ; GFX11-NEXT: [[TMP5:%.*]] = bitcast i16 [[EXTRACTED1]] to bfloat
3852 ; GFX11-NEXT: ret bfloat [[TMP5]]
3854 %res = atomicrmw fadd ptr %ptr, bfloat %value monotonic, align 4
3858 attributes #0 = { "denormal-fp-math-f32"="preserve-sign,preserve-sign" "amdgpu-unsafe-fp-atomics"="true" }
3859 attributes #1 = { strictfp "denormal-fp-math-f32"="preserve-sign,preserve-sign" "amdgpu-unsafe-fp-atomics"="true" }
3860 attributes #2 = { strictfp }