1
1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2
2
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -atomic-expand %s | FileCheck -check-prefix=CI %s
3
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
4
5
5
6
define float @test_atomicrmw_fadd_f32_flat (float * %ptr , float %value ) {
6
7
; CI-LABEL: @test_atomicrmw_fadd_f32_flat(
@@ -36,6 +37,23 @@ define float @test_atomicrmw_fadd_f32_flat(float* %ptr, float %value) {
36
37
; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
37
38
; GFX9: atomicrmw.end:
38
39
; GFX9-NEXT: ret float [[TMP6]]
40
+ ;
41
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f32_flat(
42
+ ; GFX908-NEXT: [[TMP1:%.*]] = load float, float* [[PTR:%.*]], align 4
43
+ ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
44
+ ; GFX908: atomicrmw.start:
45
+ ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
46
+ ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
47
+ ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float* [[PTR]] to i32*
48
+ ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
49
+ ; GFX908-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
50
+ ; GFX908-NEXT: [[TMP5:%.*]] = cmpxchg i32* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
51
+ ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
52
+ ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
53
+ ; GFX908-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
54
+ ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
55
+ ; GFX908: atomicrmw.end:
56
+ ; GFX908-NEXT: ret float [[TMP6]]
39
57
;
40
58
%res = atomicrmw fadd float * %ptr , float %value seq_cst
41
59
ret float %res
@@ -75,11 +93,71 @@ define float @test_atomicrmw_fadd_f32_global(float addrspace(1)* %ptr, float %va
75
93
; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
76
94
; GFX9: atomicrmw.end:
77
95
; GFX9-NEXT: ret float [[TMP6]]
96
+ ;
97
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global(
98
+ ; GFX908-NEXT: [[TMP1:%.*]] = load float, float addrspace(1)* [[PTR:%.*]], align 4
99
+ ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
100
+ ; GFX908: atomicrmw.start:
101
+ ; GFX908-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
102
+ ; GFX908-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
103
+ ; GFX908-NEXT: [[TMP2:%.*]] = bitcast float addrspace(1)* [[PTR]] to i32 addrspace(1)*
104
+ ; GFX908-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
105
+ ; GFX908-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
106
+ ; GFX908-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(1)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
107
+ ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
108
+ ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
109
+ ; GFX908-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
110
+ ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
111
+ ; GFX908: atomicrmw.end:
112
+ ; GFX908-NEXT: ret float [[TMP6]]
78
113
;
79
114
%res = atomicrmw fadd float addrspace (1 )* %ptr , float %value seq_cst
80
115
ret float %res
81
116
}
82
117
118
+ define void @test_atomicrmw_fadd_f32_global_no_use (float addrspace (1 )* %ptr , float %value ) {
119
+ ; CI-LABEL: @test_atomicrmw_fadd_f32_global_no_use(
120
+ ; CI-NEXT: [[TMP1:%.*]] = load float, float addrspace(1)* [[PTR:%.*]], align 4
121
+ ; CI-NEXT: br label [[ATOMICRMW_START:%.*]]
122
+ ; CI: atomicrmw.start:
123
+ ; CI-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
124
+ ; CI-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
125
+ ; CI-NEXT: [[TMP2:%.*]] = bitcast float addrspace(1)* [[PTR]] to i32 addrspace(1)*
126
+ ; CI-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
127
+ ; CI-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
128
+ ; CI-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(1)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
129
+ ; CI-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
130
+ ; CI-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
131
+ ; CI-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
132
+ ; CI-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
133
+ ; CI: atomicrmw.end:
134
+ ; CI-NEXT: ret void
135
+ ;
136
+ ; GFX9-LABEL: @test_atomicrmw_fadd_f32_global_no_use(
137
+ ; GFX9-NEXT: [[TMP1:%.*]] = load float, float addrspace(1)* [[PTR:%.*]], align 4
138
+ ; GFX9-NEXT: br label [[ATOMICRMW_START:%.*]]
139
+ ; GFX9: atomicrmw.start:
140
+ ; GFX9-NEXT: [[LOADED:%.*]] = phi float [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
141
+ ; GFX9-NEXT: [[NEW:%.*]] = fadd float [[LOADED]], [[VALUE:%.*]]
142
+ ; GFX9-NEXT: [[TMP2:%.*]] = bitcast float addrspace(1)* [[PTR]] to i32 addrspace(1)*
143
+ ; GFX9-NEXT: [[TMP3:%.*]] = bitcast float [[NEW]] to i32
144
+ ; GFX9-NEXT: [[TMP4:%.*]] = bitcast float [[LOADED]] to i32
145
+ ; GFX9-NEXT: [[TMP5:%.*]] = cmpxchg i32 addrspace(1)* [[TMP2]], i32 [[TMP4]], i32 [[TMP3]] seq_cst seq_cst
146
+ ; GFX9-NEXT: [[SUCCESS:%.*]] = extractvalue { i32, i1 } [[TMP5]], 1
147
+ ; GFX9-NEXT: [[NEWLOADED:%.*]] = extractvalue { i32, i1 } [[TMP5]], 0
148
+ ; GFX9-NEXT: [[TMP6]] = bitcast i32 [[NEWLOADED]] to float
149
+ ; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
150
+ ; GFX9: atomicrmw.end:
151
+ ; GFX9-NEXT: ret void
152
+ ;
153
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f32_global_no_use(
154
+ ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd float addrspace(1)* [[PTR:%.*]], float [[VALUE:%.*]] seq_cst
155
+ ; GFX908-NEXT: ret void
156
+ ;
157
+ %res = atomicrmw fadd float addrspace (1 )* %ptr , float %value seq_cst
158
+ ret void
159
+ }
160
+
83
161
define float @test_atomicrmw_fadd_f32_local (float addrspace (3 )* %ptr , float %value ) {
84
162
; CI-LABEL: @test_atomicrmw_fadd_f32_local(
85
163
; CI-NEXT: [[TMP1:%.*]] = load float, float addrspace(3)* [[PTR:%.*]], align 4
@@ -101,6 +179,10 @@ define float @test_atomicrmw_fadd_f32_local(float addrspace(3)* %ptr, float %val
101
179
; GFX9-LABEL: @test_atomicrmw_fadd_f32_local(
102
180
; GFX9-NEXT: [[RES:%.*]] = atomicrmw fadd float addrspace(3)* [[PTR:%.*]], float [[VALUE:%.*]] seq_cst
103
181
; GFX9-NEXT: ret float [[RES]]
182
+ ;
183
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f32_local(
184
+ ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd float addrspace(3)* [[PTR:%.*]], float [[VALUE:%.*]] seq_cst
185
+ ; GFX908-NEXT: ret float [[RES]]
104
186
;
105
187
%res = atomicrmw fadd float addrspace (3 )* %ptr , float %value seq_cst
106
188
ret float %res
@@ -114,6 +196,10 @@ define half @test_atomicrmw_fadd_f16_flat(half* %ptr, half %value) {
114
196
; GFX9-LABEL: @test_atomicrmw_fadd_f16_flat(
115
197
; GFX9-NEXT: [[RES:%.*]] = atomicrmw fadd half* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
116
198
; GFX9-NEXT: ret half [[RES]]
199
+ ;
200
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f16_flat(
201
+ ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd half* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
202
+ ; GFX908-NEXT: ret half [[RES]]
117
203
;
118
204
%res = atomicrmw fadd half * %ptr , half %value seq_cst
119
205
ret half %res
@@ -127,6 +213,10 @@ define half @test_atomicrmw_fadd_f16_global(half addrspace(1)* %ptr, half %value
127
213
; GFX9-LABEL: @test_atomicrmw_fadd_f16_global(
128
214
; GFX9-NEXT: [[RES:%.*]] = atomicrmw fadd half addrspace(1)* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
129
215
; GFX9-NEXT: ret half [[RES]]
216
+ ;
217
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f16_global(
218
+ ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd half addrspace(1)* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
219
+ ; GFX908-NEXT: ret half [[RES]]
130
220
;
131
221
%res = atomicrmw fadd half addrspace (1 )* %ptr , half %value seq_cst
132
222
ret half %res
@@ -140,6 +230,10 @@ define half @test_atomicrmw_fadd_f16_local(half addrspace(3)* %ptr, half %value)
140
230
; GFX9-LABEL: @test_atomicrmw_fadd_f16_local(
141
231
; GFX9-NEXT: [[RES:%.*]] = atomicrmw fadd half addrspace(3)* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
142
232
; GFX9-NEXT: ret half [[RES]]
233
+ ;
234
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f16_local(
235
+ ; GFX908-NEXT: [[RES:%.*]] = atomicrmw fadd half addrspace(3)* [[PTR:%.*]], half [[VALUE:%.*]] seq_cst
236
+ ; GFX908-NEXT: ret half [[RES]]
143
237
;
144
238
%res = atomicrmw fadd half addrspace (3 )* %ptr , half %value seq_cst
145
239
ret half %res
@@ -179,6 +273,23 @@ define double @test_atomicrmw_fadd_f64_flat(double* %ptr, double %value) {
179
273
; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
180
274
; GFX9: atomicrmw.end:
181
275
; GFX9-NEXT: ret double [[TMP6]]
276
+ ;
277
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f64_flat(
278
+ ; GFX908-NEXT: [[TMP1:%.*]] = load double, double* [[PTR:%.*]], align 8
279
+ ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
280
+ ; GFX908: atomicrmw.start:
281
+ ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
282
+ ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
283
+ ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double* [[PTR]] to i64*
284
+ ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
285
+ ; GFX908-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
286
+ ; GFX908-NEXT: [[TMP5:%.*]] = cmpxchg i64* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
287
+ ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
288
+ ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
289
+ ; GFX908-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
290
+ ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
291
+ ; GFX908: atomicrmw.end:
292
+ ; GFX908-NEXT: ret double [[TMP6]]
182
293
;
183
294
%res = atomicrmw fadd double * %ptr , double %value seq_cst
184
295
ret double %res
@@ -218,6 +329,23 @@ define double @test_atomicrmw_fadd_f64_global(double addrspace(1)* %ptr, double
218
329
; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
219
330
; GFX9: atomicrmw.end:
220
331
; GFX9-NEXT: ret double [[TMP6]]
332
+ ;
333
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f64_global(
334
+ ; GFX908-NEXT: [[TMP1:%.*]] = load double, double addrspace(1)* [[PTR:%.*]], align 8
335
+ ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
336
+ ; GFX908: atomicrmw.start:
337
+ ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
338
+ ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
339
+ ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double addrspace(1)* [[PTR]] to i64 addrspace(1)*
340
+ ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
341
+ ; GFX908-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
342
+ ; GFX908-NEXT: [[TMP5:%.*]] = cmpxchg i64 addrspace(1)* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
343
+ ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
344
+ ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
345
+ ; GFX908-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
346
+ ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
347
+ ; GFX908: atomicrmw.end:
348
+ ; GFX908-NEXT: ret double [[TMP6]]
221
349
;
222
350
%res = atomicrmw fadd double addrspace (1 )* %ptr , double %value seq_cst
223
351
ret double %res
@@ -257,6 +385,23 @@ define double @test_atomicrmw_fadd_f64_local(double addrspace(3)* %ptr, double %
257
385
; GFX9-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
258
386
; GFX9: atomicrmw.end:
259
387
; GFX9-NEXT: ret double [[TMP6]]
388
+ ;
389
+ ; GFX908-LABEL: @test_atomicrmw_fadd_f64_local(
390
+ ; GFX908-NEXT: [[TMP1:%.*]] = load double, double addrspace(3)* [[PTR:%.*]], align 8
391
+ ; GFX908-NEXT: br label [[ATOMICRMW_START:%.*]]
392
+ ; GFX908: atomicrmw.start:
393
+ ; GFX908-NEXT: [[LOADED:%.*]] = phi double [ [[TMP1]], [[TMP0:%.*]] ], [ [[TMP6:%.*]], [[ATOMICRMW_START]] ]
394
+ ; GFX908-NEXT: [[NEW:%.*]] = fadd double [[LOADED]], [[VALUE:%.*]]
395
+ ; GFX908-NEXT: [[TMP2:%.*]] = bitcast double addrspace(3)* [[PTR]] to i64 addrspace(3)*
396
+ ; GFX908-NEXT: [[TMP3:%.*]] = bitcast double [[NEW]] to i64
397
+ ; GFX908-NEXT: [[TMP4:%.*]] = bitcast double [[LOADED]] to i64
398
+ ; GFX908-NEXT: [[TMP5:%.*]] = cmpxchg i64 addrspace(3)* [[TMP2]], i64 [[TMP4]], i64 [[TMP3]] seq_cst seq_cst
399
+ ; GFX908-NEXT: [[SUCCESS:%.*]] = extractvalue { i64, i1 } [[TMP5]], 1
400
+ ; GFX908-NEXT: [[NEWLOADED:%.*]] = extractvalue { i64, i1 } [[TMP5]], 0
401
+ ; GFX908-NEXT: [[TMP6]] = bitcast i64 [[NEWLOADED]] to double
402
+ ; GFX908-NEXT: br i1 [[SUCCESS]], label [[ATOMICRMW_END:%.*]], label [[ATOMICRMW_START]]
403
+ ; GFX908: atomicrmw.end:
404
+ ; GFX908-NEXT: ret double [[TMP6]]
260
405
;
261
406
%res = atomicrmw fadd double addrspace (3 )* %ptr , double %value seq_cst
262
407
ret double %res
0 commit comments