1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2 // RUN: %clang_cc1 -fnative-half-arguments-and-returns -triple amdgcn-amd-amdhsa-gnu -target-cpu gfx900 -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,SAFE %s
3 // RUN: %clang_cc1 -fnative-half-arguments-and-returns -triple amdgcn-amd-amdhsa-gnu -target-cpu gfx900 -emit-llvm -munsafe-fp-atomics -o - %s | FileCheck -check-prefixes=CHECK,UNSAFE %s
5 // SAFE-LABEL: define dso_local float @test_float_post_inc(
6 // SAFE-SAME: ) #[[ATTR0:[0-9]+]] {
7 // SAFE-NEXT: [[ENTRY:.*:]]
8 // SAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
9 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
10 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_float_post_inc.n to ptr), float 1.000000e+00 seq_cst, align 4
11 // SAFE-NEXT: ret float [[TMP0]]
13 // UNSAFE-LABEL: define dso_local float @test_float_post_inc(
14 // UNSAFE-SAME: ) #[[ATTR0:[0-9]+]] {
15 // UNSAFE-NEXT: [[ENTRY:.*:]]
16 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
17 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
18 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_float_post_inc.n to ptr), float 1.000000e+00 seq_cst, align 4, !amdgpu.no.fine.grained.memory [[META3:![0-9]+]], !amdgpu.ignore.denormal.mode [[META3]]
19 // UNSAFE-NEXT: ret float [[TMP0]]
21 float test_float_post_inc()
23 static _Atomic
float n
;
27 // SAFE-LABEL: define dso_local float @test_float_post_dc(
28 // SAFE-SAME: ) #[[ATTR0]] {
29 // SAFE-NEXT: [[ENTRY:.*:]]
30 // SAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
31 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
32 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_float_post_dc.n to ptr), float 1.000000e+00 seq_cst, align 4
33 // SAFE-NEXT: ret float [[TMP0]]
35 // UNSAFE-LABEL: define dso_local float @test_float_post_dc(
36 // UNSAFE-SAME: ) #[[ATTR0]] {
37 // UNSAFE-NEXT: [[ENTRY:.*:]]
38 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
39 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
40 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_float_post_dc.n to ptr), float 1.000000e+00 seq_cst, align 4, !amdgpu.no.fine.grained.memory [[META3]]
41 // UNSAFE-NEXT: ret float [[TMP0]]
43 float test_float_post_dc()
45 static _Atomic
float n
;
49 // SAFE-LABEL: define dso_local float @test_float_pre_dc(
50 // SAFE-SAME: ) #[[ATTR0]] {
51 // SAFE-NEXT: [[ENTRY:.*:]]
52 // SAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
53 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
54 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_float_pre_dc.n to ptr), float 1.000000e+00 seq_cst, align 4
55 // SAFE-NEXT: [[TMP1:%.*]] = fsub float [[TMP0]], 1.000000e+00
56 // SAFE-NEXT: ret float [[TMP1]]
58 // UNSAFE-LABEL: define dso_local float @test_float_pre_dc(
59 // UNSAFE-SAME: ) #[[ATTR0]] {
60 // UNSAFE-NEXT: [[ENTRY:.*:]]
61 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
62 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
63 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_float_pre_dc.n to ptr), float 1.000000e+00 seq_cst, align 4, !amdgpu.no.fine.grained.memory [[META3]]
64 // UNSAFE-NEXT: [[TMP1:%.*]] = fsub float [[TMP0]], 1.000000e+00
65 // UNSAFE-NEXT: ret float [[TMP1]]
67 float test_float_pre_dc()
69 static _Atomic
float n
;
73 // SAFE-LABEL: define dso_local float @test_float_pre_inc(
74 // SAFE-SAME: ) #[[ATTR0]] {
75 // SAFE-NEXT: [[ENTRY:.*:]]
76 // SAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
77 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
78 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_float_pre_inc.n to ptr), float 1.000000e+00 seq_cst, align 4
79 // SAFE-NEXT: [[TMP1:%.*]] = fadd float [[TMP0]], 1.000000e+00
80 // SAFE-NEXT: ret float [[TMP1]]
82 // UNSAFE-LABEL: define dso_local float @test_float_pre_inc(
83 // UNSAFE-SAME: ) #[[ATTR0]] {
84 // UNSAFE-NEXT: [[ENTRY:.*:]]
85 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
86 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
87 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_float_pre_inc.n to ptr), float 1.000000e+00 seq_cst, align 4, !amdgpu.no.fine.grained.memory [[META3]], !amdgpu.ignore.denormal.mode [[META3]]
88 // UNSAFE-NEXT: [[TMP1:%.*]] = fadd float [[TMP0]], 1.000000e+00
89 // UNSAFE-NEXT: ret float [[TMP1]]
91 float test_float_pre_inc()
93 static _Atomic
float n
;
97 // SAFE-LABEL: define dso_local double @test_double_post_inc(
98 // SAFE-SAME: ) #[[ATTR0]] {
99 // SAFE-NEXT: [[ENTRY:.*:]]
100 // SAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
101 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
102 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_double_post_inc.n to ptr), double 1.000000e+00 seq_cst, align 8
103 // SAFE-NEXT: ret double [[TMP0]]
105 // UNSAFE-LABEL: define dso_local double @test_double_post_inc(
106 // UNSAFE-SAME: ) #[[ATTR0]] {
107 // UNSAFE-NEXT: [[ENTRY:.*:]]
108 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
109 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
110 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_double_post_inc.n to ptr), double 1.000000e+00 seq_cst, align 8, !amdgpu.no.fine.grained.memory [[META3]]
111 // UNSAFE-NEXT: ret double [[TMP0]]
113 double test_double_post_inc()
115 static _Atomic
double n
;
119 // SAFE-LABEL: define dso_local double @test_double_post_dc(
120 // SAFE-SAME: ) #[[ATTR0]] {
121 // SAFE-NEXT: [[ENTRY:.*:]]
122 // SAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
123 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
124 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_double_post_dc.n to ptr), double 1.000000e+00 seq_cst, align 8
125 // SAFE-NEXT: ret double [[TMP0]]
127 // UNSAFE-LABEL: define dso_local double @test_double_post_dc(
128 // UNSAFE-SAME: ) #[[ATTR0]] {
129 // UNSAFE-NEXT: [[ENTRY:.*:]]
130 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
131 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
132 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_double_post_dc.n to ptr), double 1.000000e+00 seq_cst, align 8, !amdgpu.no.fine.grained.memory [[META3]]
133 // UNSAFE-NEXT: ret double [[TMP0]]
135 double test_double_post_dc()
137 static _Atomic
double n
;
141 // SAFE-LABEL: define dso_local double @test_double_pre_dc(
142 // SAFE-SAME: ) #[[ATTR0]] {
143 // SAFE-NEXT: [[ENTRY:.*:]]
144 // SAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
145 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
146 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_double_pre_dc.n to ptr), double 1.000000e+00 seq_cst, align 8
147 // SAFE-NEXT: [[TMP1:%.*]] = fsub double [[TMP0]], 1.000000e+00
148 // SAFE-NEXT: ret double [[TMP1]]
150 // UNSAFE-LABEL: define dso_local double @test_double_pre_dc(
151 // UNSAFE-SAME: ) #[[ATTR0]] {
152 // UNSAFE-NEXT: [[ENTRY:.*:]]
153 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
154 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
155 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test_double_pre_dc.n to ptr), double 1.000000e+00 seq_cst, align 8, !amdgpu.no.fine.grained.memory [[META3]]
156 // UNSAFE-NEXT: [[TMP1:%.*]] = fsub double [[TMP0]], 1.000000e+00
157 // UNSAFE-NEXT: ret double [[TMP1]]
159 double test_double_pre_dc()
161 static _Atomic
double n
;
165 // SAFE-LABEL: define dso_local double @test_double_pre_inc(
166 // SAFE-SAME: ) #[[ATTR0]] {
167 // SAFE-NEXT: [[ENTRY:.*:]]
168 // SAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
169 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
170 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_double_pre_inc.n to ptr), double 1.000000e+00 seq_cst, align 8
171 // SAFE-NEXT: [[TMP1:%.*]] = fadd double [[TMP0]], 1.000000e+00
172 // SAFE-NEXT: ret double [[TMP1]]
174 // UNSAFE-LABEL: define dso_local double @test_double_pre_inc(
175 // UNSAFE-SAME: ) #[[ATTR0]] {
176 // UNSAFE-NEXT: [[ENTRY:.*:]]
177 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca double, align 8, addrspace(5)
178 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
179 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test_double_pre_inc.n to ptr), double 1.000000e+00 seq_cst, align 8, !amdgpu.no.fine.grained.memory [[META3]]
180 // UNSAFE-NEXT: [[TMP1:%.*]] = fadd double [[TMP0]], 1.000000e+00
181 // UNSAFE-NEXT: ret double [[TMP1]]
183 double test_double_pre_inc()
185 static _Atomic
double n
;
189 // SAFE-LABEL: define dso_local half @test__Float16_post_inc(
190 // SAFE-SAME: ) #[[ATTR0]] {
191 // SAFE-NEXT: [[ENTRY:.*:]]
192 // SAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
193 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
194 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test__Float16_post_inc.n to ptr), half 0xH3C00 seq_cst, align 2
195 // SAFE-NEXT: ret half [[TMP0]]
197 // UNSAFE-LABEL: define dso_local half @test__Float16_post_inc(
198 // UNSAFE-SAME: ) #[[ATTR0]] {
199 // UNSAFE-NEXT: [[ENTRY:.*:]]
200 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
201 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
202 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test__Float16_post_inc.n to ptr), half 0xH3C00 seq_cst, align 2, !amdgpu.no.fine.grained.memory [[META3]]
203 // UNSAFE-NEXT: ret half [[TMP0]]
205 _Float16
test__Float16_post_inc()
207 static _Atomic _Float16 n
;
211 // SAFE-LABEL: define dso_local half @test__Float16_post_dc(
212 // SAFE-SAME: ) #[[ATTR0]] {
213 // SAFE-NEXT: [[ENTRY:.*:]]
214 // SAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
215 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
216 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test__Float16_post_dc.n to ptr), half 0xH3C00 seq_cst, align 2
217 // SAFE-NEXT: ret half [[TMP0]]
219 // UNSAFE-LABEL: define dso_local half @test__Float16_post_dc(
220 // UNSAFE-SAME: ) #[[ATTR0]] {
221 // UNSAFE-NEXT: [[ENTRY:.*:]]
222 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
223 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
224 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test__Float16_post_dc.n to ptr), half 0xH3C00 seq_cst, align 2, !amdgpu.no.fine.grained.memory [[META3]]
225 // UNSAFE-NEXT: ret half [[TMP0]]
227 _Float16
test__Float16_post_dc()
229 static _Atomic _Float16 n
;
233 // SAFE-LABEL: define dso_local half @test__Float16_pre_dc(
234 // SAFE-SAME: ) #[[ATTR0]] {
235 // SAFE-NEXT: [[ENTRY:.*:]]
236 // SAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
237 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
238 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test__Float16_pre_dc.n to ptr), half 0xH3C00 seq_cst, align 2
239 // SAFE-NEXT: [[TMP1:%.*]] = fsub half [[TMP0]], 0xH3C00
240 // SAFE-NEXT: ret half [[TMP1]]
242 // UNSAFE-LABEL: define dso_local half @test__Float16_pre_dc(
243 // UNSAFE-SAME: ) #[[ATTR0]] {
244 // UNSAFE-NEXT: [[ENTRY:.*:]]
245 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
246 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
247 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fsub ptr addrspacecast (ptr addrspace(1) @test__Float16_pre_dc.n to ptr), half 0xH3C00 seq_cst, align 2, !amdgpu.no.fine.grained.memory [[META3]]
248 // UNSAFE-NEXT: [[TMP1:%.*]] = fsub half [[TMP0]], 0xH3C00
249 // UNSAFE-NEXT: ret half [[TMP1]]
251 _Float16
test__Float16_pre_dc()
253 static _Atomic _Float16 n
;
257 // SAFE-LABEL: define dso_local half @test__Float16_pre_inc(
258 // SAFE-SAME: ) #[[ATTR0]] {
259 // SAFE-NEXT: [[ENTRY:.*:]]
260 // SAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
261 // SAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
262 // SAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test__Float16_pre_inc.n to ptr), half 0xH3C00 seq_cst, align 2
263 // SAFE-NEXT: [[TMP1:%.*]] = fadd half [[TMP0]], 0xH3C00
264 // SAFE-NEXT: ret half [[TMP1]]
266 // UNSAFE-LABEL: define dso_local half @test__Float16_pre_inc(
267 // UNSAFE-SAME: ) #[[ATTR0]] {
268 // UNSAFE-NEXT: [[ENTRY:.*:]]
269 // UNSAFE-NEXT: [[RETVAL:%.*]] = alloca half, align 2, addrspace(5)
270 // UNSAFE-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
271 // UNSAFE-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr addrspacecast (ptr addrspace(1) @test__Float16_pre_inc.n to ptr), half 0xH3C00 seq_cst, align 2, !amdgpu.no.fine.grained.memory [[META3]]
272 // UNSAFE-NEXT: [[TMP1:%.*]] = fadd half [[TMP0]], 0xH3C00
273 // UNSAFE-NEXT: ret half [[TMP1]]
275 _Float16
test__Float16_pre_inc()
277 static _Atomic _Float16 n
;
281 // UNSAFE: [[META3]] = !{}
283 //// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: