Debian Codegraph @

clang/test/CodeGen/builtins-nvptx.c

raw
1 // REQUIRES: nvptx-registered-target
2 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_70 -target-feature +ptx63 \
3 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
4 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX63_SM70 -check-prefix=LP64 %s
5 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx-unknown-unknown -target-cpu sm_80 -target-feature +ptx70 \
6 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
7 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX70_SM80 -check-prefix=LP32 %s
8 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_80 -target-feature +ptx70 \
9 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
10 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX70_SM80 -check-prefix=LP64 %s
11 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx-unknown-unknown -target-cpu sm_60 -target-feature +ptx62 \
12 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
13 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=LP32 %s
14 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_60 -target-feature +ptx62 \
15 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
16 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
17 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_61 -target-feature +ptx62 \
18 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
19 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
20 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 -target-feature +ptx62 \
21 // RUN: -DERROR_CHECK -fcuda-is-device -S -o /dev/null -x cuda -verify %s
22 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx-unknown-unknown -target-cpu sm_86 -target-feature +ptx72 \
23 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
24 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX72_SM86 -check-prefix=LP32 %s
25 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_86 -target-feature +ptx72 \
26 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
27 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX72_SM86 -check-prefix=LP64 %s
28 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_89 -target-feature +ptx81 -DPTX=81\
29 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
30 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM89 %s
31 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_80 -target-feature +ptx81 -DPTX=81 \
32 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
33 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX81_SM80 %s
34 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_90 -target-feature +ptx78 -DPTX=78 \
35 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
36 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX78_SM90 %s
37 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_100 -target-feature +ptx86 -DPTX=86 \
38 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
39 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX86_SM100 %s
40 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_100a -target-feature +ptx86 -DPTX=86 \
41 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
42 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX86_SM100a %s
43 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_101a -target-feature +ptx86 -DPTX=86 \
44 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
45 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX86_SM101a %s
46 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_120a -target-feature +ptx87 -DPTX=87 \
47 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
48 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX86_SM120a %s
49 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_103a -target-feature +ptx88 -DPTX=88 \
50 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
51 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX87_SM103a %s
52 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_100a -target-feature +ptx87 -DPTX=87 \
53 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
54 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX87_SM100a %s
55 // ### The last run to check with the highest SM and PTX version available
56 // ### to make sure target builtins are still accepted.
57 // RUN: %clang_cc1 -ffp-contract=off -triple nvptx64-unknown-unknown -target-cpu sm_120a -target-feature +ptx87 -DPTX=87 \
58 // RUN: -disable-llvm-optzns -fcuda-is-device -emit-llvm -o - -x cuda %s \
59 // RUN: | FileCheck -check-prefix=CHECK -check-prefix=CHECK_PTX86_SM120a %s
60
61 #define __device__ __attribute__((device))
62 #define __global__ __attribute__((global))
63 #define __shared__ __attribute__((shared))
64 #define __constant__ __attribute__((constant))
65
66 __device__ int read_tid() {
67
68 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
69 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.tid.y()
70 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.tid.z()
71 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.tid.w()
72
73 int x = __nvvm_read_ptx_sreg_tid_x();
74 int y = __nvvm_read_ptx_sreg_tid_y();
75 int z = __nvvm_read_ptx_sreg_tid_z();
76 int w = __nvvm_read_ptx_sreg_tid_w();
77
78 return x + y + z + w;
79
80 }
81
82 __device__ bool reflect() {
83
84 // CHECK: call i32 @llvm.nvvm.reflect(ptr {{.*}})
85
86 unsigned x = __nvvm_reflect("__CUDA_ARCH");
87 return x >= 700;
88
89 }
90
91 __device__ int read_ntid() {
92
93 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
94 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ntid.y()
95 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ntid.z()
96 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ntid.w()
97
98 int x = __nvvm_read_ptx_sreg_ntid_x();
99 int y = __nvvm_read_ptx_sreg_ntid_y();
100 int z = __nvvm_read_ptx_sreg_ntid_z();
101 int w = __nvvm_read_ptx_sreg_ntid_w();
102
103 return x + y + z + w;
104
105 }
106
107 __device__ int read_ctaid() {
108
109 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
110 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ctaid.y()
111 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ctaid.z()
112 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.ctaid.w()
113
114 int x = __nvvm_read_ptx_sreg_ctaid_x();
115 int y = __nvvm_read_ptx_sreg_ctaid_y();
116 int z = __nvvm_read_ptx_sreg_ctaid_z();
117 int w = __nvvm_read_ptx_sreg_ctaid_w();
118
119 return x + y + z + w;
120
121 }
122
123 __device__ int read_nctaid() {
124
125 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nctaid.x()
126 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nctaid.y()
127 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nctaid.z()
128 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nctaid.w()
129
130 int x = __nvvm_read_ptx_sreg_nctaid_x();
131 int y = __nvvm_read_ptx_sreg_nctaid_y();
132 int z = __nvvm_read_ptx_sreg_nctaid_z();
133 int w = __nvvm_read_ptx_sreg_nctaid_w();
134
135 return x + y + z + w;
136
137 }
138
139 __device__ int read_ids() {
140
141 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.laneid()
142 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.warpid()
143 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nwarpid()
144 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.smid()
145 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nsmid()
146 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.gridid()
147 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
148
149 int a = __nvvm_read_ptx_sreg_laneid();
150 int b = __nvvm_read_ptx_sreg_warpid();
151 int c = __nvvm_read_ptx_sreg_nwarpid();
152 int d = __nvvm_read_ptx_sreg_smid();
153 int e = __nvvm_read_ptx_sreg_nsmid();
154 int f = __nvvm_read_ptx_sreg_gridid();
155 int g = __nvvm_read_ptx_sreg_warpsize();
156
157 return a + b + c + d + e + f + g;
158
159 }
160
161 __device__ int read_lanemasks() {
162
163 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.lanemask.eq()
164 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.lanemask.le()
165 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.lanemask.lt()
166 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.lanemask.ge()
167 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.lanemask.gt()
168
169 int a = __nvvm_read_ptx_sreg_lanemask_eq();
170 int b = __nvvm_read_ptx_sreg_lanemask_le();
171 int c = __nvvm_read_ptx_sreg_lanemask_lt();
172 int d = __nvvm_read_ptx_sreg_lanemask_ge();
173 int e = __nvvm_read_ptx_sreg_lanemask_gt();
174
175 return a + b + c + d + e;
176
177 }
178
179 __device__ long long read_clocks() {
180
181 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.clock()
182 // CHECK: call i64 @llvm.nvvm.read.ptx.sreg.clock64()
183 // CHECK: call i64 @llvm.nvvm.read.ptx.sreg.globaltimer()
184
185 int a = __nvvm_read_ptx_sreg_clock();
186 long long b = __nvvm_read_ptx_sreg_clock64();
187 long long c = __nvvm_read_ptx_sreg_globaltimer();
188
189 return a + b + c;
190 }
191
192 __device__ int read_pms() {
193
194 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.pm0()
195 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.pm1()
196 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.pm2()
197 // CHECK: call i32 @llvm.nvvm.read.ptx.sreg.pm3()
198
199 int a = __nvvm_read_ptx_sreg_pm0();
200 int b = __nvvm_read_ptx_sreg_pm1();
201 int c = __nvvm_read_ptx_sreg_pm2();
202 int d = __nvvm_read_ptx_sreg_pm3();
203
204 return a + b + c + d;
205
206 }
207
208 __device__ void sync() {
209
210 // CHECK: call void @llvm.nvvm.barrier.cta.sync.aligned.all(i32 0)
211
212 __nvvm_bar_sync(0);
213
214 }
215
216 __device__ void activemask() {
217
218 // CHECK: call i32 @llvm.nvvm.activemask()
219
220 __nvvm_activemask();
221
222 }
223
224 __device__ void exit() {
225
226 // CHECK: call void @llvm.nvvm.exit()
227
228 __nvvm_exit();
229
230 }
231
232 // NVVM intrinsics
233
234 // The idea is not to test all intrinsics, just that Clang is recognizing the
235 // builtins defined in BuiltinsNVPTX.td
236 __device__ void nvvm_math(float f1, float f2, double d1, double d2) {
237 // CHECK: call float @llvm.nvvm.fmax.f
238 float t1 = __nvvm_fmax_f(f1, f2);
239 // CHECK: call float @llvm.nvvm.fmin.f
240 float t2 = __nvvm_fmin_f(f1, f2);
241 // CHECK: call float @llvm.nvvm.sqrt.rn.f
242 float t3 = __nvvm_sqrt_rn_f(f1);
243 // CHECK: call float @llvm.nvvm.rcp.rn.f
244 float t4 = __nvvm_rcp_rn_f(f2);
245 // CHECK: call float @llvm.nvvm.add.rn.f
246 float t5 = __nvvm_add_rn_f(f1, f2);
247
248 // CHECK: call double @llvm.nvvm.fmax.d
249 double td1 = __nvvm_fmax_d(d1, d2);
250 // CHECK: call double @llvm.nvvm.fmin.d
251 double td2 = __nvvm_fmin_d(d1, d2);
252 // CHECK: call double @llvm.nvvm.sqrt.rn.d
253 double td3 = __nvvm_sqrt_rn_d(d1);
254 // CHECK: call double @llvm.nvvm.rcp.rn.d
255 double td4 = __nvvm_rcp_rn_d(d2);
256
257 // CHECK: call float @llvm.nvvm.fabs.f32
258 float t6 = __nvvm_fabs_f(f1);
259 // CHECK: call float @llvm.nvvm.fabs.ftz.f32
260 float t7 = __nvvm_fabs_ftz_f(f2);
261
262 // CHECK: call double @llvm.fabs.f64
263 double td5 = __nvvm_fabs_d(d1);
264
265 // CHECK: call void @llvm.nvvm.membar.cta()
266 __nvvm_membar_cta();
267 // CHECK: call void @llvm.nvvm.membar.gl()
268 __nvvm_membar_gl();
269 // CHECK: call void @llvm.nvvm.membar.sys()
270 __nvvm_membar_sys();
271 // CHECK: call void @llvm.nvvm.barrier.cta.sync.aligned.all(i32 0)
272 __syncthreads();
273 }
274
275 __device__ int nvvm_bar0_reductions(int i) {
276 // CHECK-LABEL: nvvm_bar0_reductions
277
278 int ret = 0;
279 // CHECK: %[[NE:[0-9]+]] = icmp ne i32 %{{[0-9]+}}, 0
280 // CHECK: %[[AND:[0-9]+]] = call i1 @llvm.nvvm.barrier.cta.red.and.aligned.all(i32 0, i1 %[[NE]])
281 // CHECK: zext i1 %[[AND]] to i32
282 ret += __nvvm_bar0_and(i);
283
284 // CHECK: %[[NE:[0-9]+]] = icmp ne i32 %{{[0-9]+}}, 0
285 // CHECK: %[[OR:[0-9]+]] = call i1 @llvm.nvvm.barrier.cta.red.or.aligned.all(i32 0, i1 %[[NE]])
286 // CHECK: zext i1 %[[OR]] to i32
287 ret += __nvvm_bar0_or(i);
288
289 // CHECK: %[[NE:[0-9]+]] = icmp ne i32 %{{[0-9]+}}, 0
290 // CHECK: %[[POPC:[0-9]+]] = call i32 @llvm.nvvm.barrier.cta.red.popc.aligned.all(i32 0, i1 %[[NE]])
291 ret += __nvvm_bar0_popc(i);
292
293 return ret;
294 }
295
296 __device__ int di;
297 __shared__ int si;
298 __device__ long dl;
299 __shared__ long sl;
300 __device__ long long dll;
301 __shared__ long long sll;
302
303 // Check for atomic intrinsics
304 // CHECK-LABEL: nvvm_atom
305 __device__ void nvvm_atom(float *fp, float f, double *dfp, double df,
306 unsigned short *usp, unsigned short us, int *ip,
307 int i, unsigned int *uip, unsigned ui, long *lp,
308 long l, long long *llp, long long ll) {
309 // CHECK: atomicrmw add ptr {{.*}} seq_cst, align 4
310 __nvvm_atom_add_gen_i(ip, i);
311 // CHECK: atomicrmw add ptr {{.*}} seq_cst, align {{4|8}}
312 __nvvm_atom_add_gen_l(&dl, l);
313 // CHECK: atomicrmw add ptr {{.*}} seq_cst, align 8
314 __nvvm_atom_add_gen_ll(&sll, ll);
315
316 // CHECK: atomicrmw sub ptr {{.*}} seq_cst, align 4
317 __nvvm_atom_sub_gen_i(ip, i);
318 // CHECK: atomicrmw sub ptr {{.*}} seq_cst, align {{4|8}}
319 __nvvm_atom_sub_gen_l(&dl, l);
320 // CHECK: atomicrmw sub ptr {{.*}} seq_cst, align 8
321 __nvvm_atom_sub_gen_ll(&sll, ll);
322
323 // CHECK: atomicrmw and ptr {{.*}} seq_cst, align 4
324 __nvvm_atom_and_gen_i(ip, i);
325 // CHECK: atomicrmw and ptr {{.*}} seq_cst, align {{4|8}}
326 __nvvm_atom_and_gen_l(&dl, l);
327 // CHECK: atomicrmw and ptr {{.*}} seq_cst, align 8
328 __nvvm_atom_and_gen_ll(&sll, ll);
329
330 // CHECK: atomicrmw or ptr {{.*}} seq_cst, align 4
331 __nvvm_atom_or_gen_i(ip, i);
332 // CHECK: atomicrmw or ptr {{.*}} seq_cst, align {{4|8}}
333 __nvvm_atom_or_gen_l(&dl, l);
334 // CHECK: atomicrmw or ptr {{.*}} seq_cst, align 8
335 __nvvm_atom_or_gen_ll(&sll, ll);
336
337 // CHECK: atomicrmw xor ptr {{.*}} seq_cst, align 4
338 __nvvm_atom_xor_gen_i(ip, i);
339 // CHECK: atomicrmw xor ptr {{.*}} seq_cst, align {{4|8}}
340 __nvvm_atom_xor_gen_l(&dl, l);
341 // CHECK: atomicrmw xor ptr {{.*}} seq_cst, align 8
342 __nvvm_atom_xor_gen_ll(&sll, ll);
343
344 // CHECK: atomicrmw xchg ptr {{.*}} seq_cst, align 4
345 __nvvm_atom_xchg_gen_i(ip, i);
346 // CHECK: atomicrmw xchg ptr {{.*}} seq_cst, align {{4|8}}
347 __nvvm_atom_xchg_gen_l(&dl, l);
348 // CHECK: atomicrmw xchg ptr {{.*}} seq_cst, align 8
349 __nvvm_atom_xchg_gen_ll(&sll, ll);
350
351 // CHECK: atomicrmw max ptr {{.*}} seq_cst, align 4
352 __nvvm_atom_max_gen_i(ip, i);
353 // CHECK: atomicrmw umax ptr {{.*}} seq_cst, align 4
354 __nvvm_atom_max_gen_ui((unsigned int *)ip, i);
355 // CHECK: atomicrmw max ptr {{.*}} seq_cst, align {{4|8}}
356 __nvvm_atom_max_gen_l(&dl, l);
357 // CHECK: atomicrmw umax ptr {{.*}} seq_cst, align {{4|8}}
358 __nvvm_atom_max_gen_ul((unsigned long *)&dl, l);
359 // CHECK: atomicrmw max ptr {{.*}} seq_cst, align 8
360 __nvvm_atom_max_gen_ll(&sll, ll);
361 // CHECK: atomicrmw umax ptr {{.*}} seq_cst, align 8
362 __nvvm_atom_max_gen_ull((unsigned long long *)&sll, ll);
363
364 // CHECK: atomicrmw min ptr {{.*}} seq_cst, align 4
365 __nvvm_atom_min_gen_i(ip, i);
366 // CHECK: atomicrmw umin ptr {{.*}} seq_cst, align 4
367 __nvvm_atom_min_gen_ui((unsigned int *)ip, i);
368 // CHECK: atomicrmw min ptr {{.*}} seq_cst, align {{4|8}}
369 __nvvm_atom_min_gen_l(&dl, l);
370 // CHECK: atomicrmw umin ptr {{.*}} seq_cst, align {{4|8}}
371 __nvvm_atom_min_gen_ul((unsigned long *)&dl, l);
372 // CHECK: atomicrmw min ptr {{.*}} seq_cst, align 8
373 __nvvm_atom_min_gen_ll(&sll, ll);
374 // CHECK: atomicrmw umin ptr {{.*}} seq_cst, align 8
375 __nvvm_atom_min_gen_ull((unsigned long long *)&sll, ll);
376
377 // CHECK: cmpxchg ptr {{.*}} seq_cst seq_cst, align 4
378 // CHECK-NEXT: extractvalue { i32, i1 } {{%[0-9]+}}, 0
379 __nvvm_atom_cas_gen_i(ip, 0, i);
380 // CHECK: cmpxchg ptr {{.*}} seq_cst seq_cst, align {{4|8}}
381 // CHECK-NEXT: extractvalue { {{i32|i64}}, i1 } {{%[0-9]+}}, 0
382 __nvvm_atom_cas_gen_l(&dl, 0, l);
383 // CHECK: cmpxchg ptr {{.*}} seq_cst seq_cst, align 8
384 // CHECK-NEXT: extractvalue { i64, i1 } {{%[0-9]+}}, 0
385 __nvvm_atom_cas_gen_ll(&sll, 0, ll);
386
387 // CHECK: atomicrmw fadd ptr {{.*}} seq_cst, align 4
388 __nvvm_atom_add_gen_f(fp, f);
389
390 // CHECK: atomicrmw uinc_wrap ptr {{.*}} seq_cst, align 4
391 __nvvm_atom_inc_gen_ui(uip, ui);
392
393 // CHECK: atomicrmw udec_wrap ptr {{.*}} seq_cst, align 4
394 __nvvm_atom_dec_gen_ui(uip, ui);
395
396
397 //////////////////////////////////////////////////////////////////
398 // Atomics with scope (only supported on sm_60+).
399
400 #if ERROR_CHECK || __CUDA_ARCH__ >= 600
401
402 // CHECK: call i32 @llvm.nvvm.atomic.add.gen.i.cta.i32.p0
403 // expected-error@+1 {{'__nvvm_atom_cta_add_gen_i' needs target feature sm_60}}
404 __nvvm_atom_cta_add_gen_i(ip, i);
405 // LP32: call i32 @llvm.nvvm.atomic.add.gen.i.cta.i32.p0
406 // LP64: call i64 @llvm.nvvm.atomic.add.gen.i.cta.i64.p0
407 // expected-error@+1 {{'__nvvm_atom_cta_add_gen_l' needs target feature sm_60}}
408 __nvvm_atom_cta_add_gen_l(&dl, l);
409 // CHECK: call i64 @llvm.nvvm.atomic.add.gen.i.cta.i64.p0
410 // expected-error@+1 {{'__nvvm_atom_cta_add_gen_ll' needs target feature sm_60}}
411 __nvvm_atom_cta_add_gen_ll(&sll, ll);
412 // CHECK: call i32 @llvm.nvvm.atomic.add.gen.i.sys.i32.p0
413 // expected-error@+1 {{'__nvvm_atom_sys_add_gen_i' needs target feature sm_60}}
414 __nvvm_atom_sys_add_gen_i(ip, i);
415 // LP32: call i32 @llvm.nvvm.atomic.add.gen.i.sys.i32.p0
416 // LP64: call i64 @llvm.nvvm.atomic.add.gen.i.sys.i64.p0
417 // expected-error@+1 {{'__nvvm_atom_sys_add_gen_l' needs target feature sm_60}}
418 __nvvm_atom_sys_add_gen_l(&dl, l);
419 // CHECK: call i64 @llvm.nvvm.atomic.add.gen.i.sys.i64.p0
420 // expected-error@+1 {{'__nvvm_atom_sys_add_gen_ll' needs target feature sm_60}}
421 __nvvm_atom_sys_add_gen_ll(&sll, ll);
422
423 // CHECK: call float @llvm.nvvm.atomic.add.gen.f.cta.f32.p0
424 // expected-error@+1 {{'__nvvm_atom_cta_add_gen_f' needs target feature sm_60}}
425 __nvvm_atom_cta_add_gen_f(fp, f);
426 // CHECK: call double @llvm.nvvm.atomic.add.gen.f.cta.f64.p0
427 // expected-error@+1 {{'__nvvm_atom_cta_add_gen_d' needs target feature sm_60}}
428 __nvvm_atom_cta_add_gen_d(dfp, df);
429 // CHECK: call float @llvm.nvvm.atomic.add.gen.f.sys.f32.p0
430 // expected-error@+1 {{'__nvvm_atom_sys_add_gen_f' needs target feature sm_60}}
431 __nvvm_atom_sys_add_gen_f(fp, f);
432 // CHECK: call double @llvm.nvvm.atomic.add.gen.f.sys.f64.p0
433 // expected-error@+1 {{'__nvvm_atom_sys_add_gen_d' needs target feature sm_60}}
434 __nvvm_atom_sys_add_gen_d(dfp, df);
435
436 // CHECK: call i32 @llvm.nvvm.atomic.exch.gen.i.cta.i32.p0
437 // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_i' needs target feature sm_60}}
438 __nvvm_atom_cta_xchg_gen_i(ip, i);
439 // LP32: call i32 @llvm.nvvm.atomic.exch.gen.i.cta.i32.p0
440 // LP64: call i64 @llvm.nvvm.atomic.exch.gen.i.cta.i64.p0
441 // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_l' needs target feature sm_60}}
442 __nvvm_atom_cta_xchg_gen_l(&dl, l);
443 // CHECK: call i64 @llvm.nvvm.atomic.exch.gen.i.cta.i64.p0
444 // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_ll' needs target feature sm_60}}
445 __nvvm_atom_cta_xchg_gen_ll(&sll, ll);
446
447 // CHECK: call i32 @llvm.nvvm.atomic.exch.gen.i.sys.i32.p0
448 // expected-error@+1 {{'__nvvm_atom_sys_xchg_gen_i' needs target feature sm_60}}
449 __nvvm_atom_sys_xchg_gen_i(ip, i);
450 // LP32: call i32 @llvm.nvvm.atomic.exch.gen.i.sys.i32.p0
451 // LP64: call i64 @llvm.nvvm.atomic.exch.gen.i.sys.i64.p0
452 // expected-error@+1 {{'__nvvm_atom_sys_xchg_gen_l' needs target feature sm_60}}
453 __nvvm_atom_sys_xchg_gen_l(&dl, l);
454 // CHECK: call i64 @llvm.nvvm.atomic.exch.gen.i.sys.i64.p0
455 // expected-error@+1 {{'__nvvm_atom_sys_xchg_gen_ll' needs target feature sm_60}}
456 __nvvm_atom_sys_xchg_gen_ll(&sll, ll);
457
458 // CHECK: call i32 @llvm.nvvm.atomic.max.gen.i.cta.i32.p0
459 // expected-error@+1 {{'__nvvm_atom_cta_max_gen_i' needs target feature sm_60}}
460 __nvvm_atom_cta_max_gen_i(ip, i);
461 // CHECK: call i32 @llvm.nvvm.atomic.max.gen.i.cta.i32.p0
462 // expected-error@+1 {{'__nvvm_atom_cta_max_gen_ui' needs target feature sm_60}}
463 __nvvm_atom_cta_max_gen_ui((unsigned int *)ip, i);
464 // LP32: call i32 @llvm.nvvm.atomic.max.gen.i.cta.i32.p0
465 // LP64: call i64 @llvm.nvvm.atomic.max.gen.i.cta.i64.p0
466 // expected-error@+1 {{'__nvvm_atom_cta_max_gen_l' needs target feature sm_60}}
467 __nvvm_atom_cta_max_gen_l(&dl, l);
468 // LP32: call i32 @llvm.nvvm.atomic.max.gen.i.cta.i32.p0
469 // LP64: call i64 @llvm.nvvm.atomic.max.gen.i.cta.i64.p0
470 // expected-error@+1 {{'__nvvm_atom_cta_max_gen_ul' needs target feature sm_60}}
471 __nvvm_atom_cta_max_gen_ul((unsigned long *)lp, l);
472 // CHECK: call i64 @llvm.nvvm.atomic.max.gen.i.cta.i64.p0
473 // expected-error@+1 {{'__nvvm_atom_cta_max_gen_ll' needs target feature sm_60}}
474 __nvvm_atom_cta_max_gen_ll(&sll, ll);
475 // CHECK: call i64 @llvm.nvvm.atomic.max.gen.i.cta.i64.p0
476 // expected-error@+1 {{'__nvvm_atom_cta_max_gen_ull' needs target feature sm_60}}
477 __nvvm_atom_cta_max_gen_ull((unsigned long long *)llp, ll);
478
479 // CHECK: call i32 @llvm.nvvm.atomic.max.gen.i.sys.i32.p0
480 // expected-error@+1 {{'__nvvm_atom_sys_max_gen_i' needs target feature sm_60}}
481 __nvvm_atom_sys_max_gen_i(ip, i);
482 // CHECK: call i32 @llvm.nvvm.atomic.max.gen.i.sys.i32.p0
483 // expected-error@+1 {{'__nvvm_atom_sys_max_gen_ui' needs target feature sm_60}}
484 __nvvm_atom_sys_max_gen_ui((unsigned int *)ip, i);
485 // LP32: call i32 @llvm.nvvm.atomic.max.gen.i.sys.i32.p0
486 // LP64: call i64 @llvm.nvvm.atomic.max.gen.i.sys.i64.p0
487 // expected-error@+1 {{'__nvvm_atom_sys_max_gen_l' needs target feature sm_60}}
488 __nvvm_atom_sys_max_gen_l(&dl, l);
489 // LP32: call i32 @llvm.nvvm.atomic.max.gen.i.sys.i32.p0
490 // LP64: call i64 @llvm.nvvm.atomic.max.gen.i.sys.i64.p0
491 // expected-error@+1 {{'__nvvm_atom_sys_max_gen_ul' needs target feature sm_60}}
492 __nvvm_atom_sys_max_gen_ul((unsigned long *)lp, l);
493 // CHECK: call i64 @llvm.nvvm.atomic.max.gen.i.sys.i64.p0
494 // expected-error@+1 {{'__nvvm_atom_sys_max_gen_ll' needs target feature sm_60}}
495 __nvvm_atom_sys_max_gen_ll(&sll, ll);
496 // CHECK: call i64 @llvm.nvvm.atomic.max.gen.i.sys.i64.p0
497 // expected-error@+1 {{'__nvvm_atom_sys_max_gen_ull' needs target feature sm_60}}
498 __nvvm_atom_sys_max_gen_ull((unsigned long long *)llp, ll);
499
500 // CHECK: call i32 @llvm.nvvm.atomic.min.gen.i.cta.i32.p0
501 // expected-error@+1 {{'__nvvm_atom_cta_min_gen_i' needs target feature sm_60}}
502 __nvvm_atom_cta_min_gen_i(ip, i);
503 // CHECK: call i32 @llvm.nvvm.atomic.min.gen.i.cta.i32.p0
504 // expected-error@+1 {{'__nvvm_atom_cta_min_gen_ui' needs target feature sm_60}}
505 __nvvm_atom_cta_min_gen_ui((unsigned int *)ip, i);
506 // LP32: call i32 @llvm.nvvm.atomic.min.gen.i.cta.i32.p0
507 // LP64: call i64 @llvm.nvvm.atomic.min.gen.i.cta.i64.p0
508 // expected-error@+1 {{'__nvvm_atom_cta_min_gen_l' needs target feature sm_60}}
509 __nvvm_atom_cta_min_gen_l(&dl, l);
510 // LP32: call i32 @llvm.nvvm.atomic.min.gen.i.cta.i32.p0
511 // LP64: call i64 @llvm.nvvm.atomic.min.gen.i.cta.i64.p0
512 // expected-error@+1 {{'__nvvm_atom_cta_min_gen_ul' needs target feature sm_60}}
513 __nvvm_atom_cta_min_gen_ul((unsigned long *)lp, l);
514 // CHECK: call i64 @llvm.nvvm.atomic.min.gen.i.cta.i64.p0
515 // expected-error@+1 {{'__nvvm_atom_cta_min_gen_ll' needs target feature sm_60}}
516 __nvvm_atom_cta_min_gen_ll(&sll, ll);
517 // CHECK: call i64 @llvm.nvvm.atomic.min.gen.i.cta.i64.p0
518 // expected-error@+1 {{'__nvvm_atom_cta_min_gen_ull' needs target feature sm_60}}
519 __nvvm_atom_cta_min_gen_ull((unsigned long long *)llp, ll);
520
521 // CHECK: call i32 @llvm.nvvm.atomic.min.gen.i.sys.i32.p0
522 // expected-error@+1 {{'__nvvm_atom_sys_min_gen_i' needs target feature sm_60}}
523 __nvvm_atom_sys_min_gen_i(ip, i);
524 // CHECK: call i32 @llvm.nvvm.atomic.min.gen.i.sys.i32.p0
525 // expected-error@+1 {{'__nvvm_atom_sys_min_gen_ui' needs target feature sm_60}}
526 __nvvm_atom_sys_min_gen_ui((unsigned int *)ip, i);
527 // LP32: call i32 @llvm.nvvm.atomic.min.gen.i.sys.i32.p0
528 // LP64: call i64 @llvm.nvvm.atomic.min.gen.i.sys.i64.p0
529 // expected-error@+1 {{'__nvvm_atom_sys_min_gen_l' needs target feature sm_60}}
530 __nvvm_atom_sys_min_gen_l(&dl, l);
531 // LP32: call i32 @llvm.nvvm.atomic.min.gen.i.sys.i32.p0
532 // LP64: call i64 @llvm.nvvm.atomic.min.gen.i.sys.i64.p0
533 // expected-error@+1 {{'__nvvm_atom_sys_min_gen_ul' needs target feature sm_60}}
534 __nvvm_atom_sys_min_gen_ul((unsigned long *)lp, l);
535 // CHECK: call i64 @llvm.nvvm.atomic.min.gen.i.sys.i64.p0
536 // expected-error@+1 {{'__nvvm_atom_sys_min_gen_ll' needs target feature sm_60}}
537 __nvvm_atom_sys_min_gen_ll(&sll, ll);
538 // CHECK: call i64 @llvm.nvvm.atomic.min.gen.i.sys.i64.p0
539 // expected-error@+1 {{'__nvvm_atom_sys_min_gen_ull' needs target feature sm_60}}
540 __nvvm_atom_sys_min_gen_ull((unsigned long long *)llp, ll);
541
542 // CHECK: call i32 @llvm.nvvm.atomic.inc.gen.i.cta.i32.p0
543 // expected-error@+1 {{'__nvvm_atom_cta_inc_gen_ui' needs target feature sm_60}}
544 __nvvm_atom_cta_inc_gen_ui((unsigned int *)ip, i);
545 // CHECK: call i32 @llvm.nvvm.atomic.inc.gen.i.sys.i32.p0
546 // expected-error@+1 {{'__nvvm_atom_sys_inc_gen_ui' needs target feature sm_60}}
547 __nvvm_atom_sys_inc_gen_ui((unsigned int *)ip, i);
548
549 // CHECK: call i32 @llvm.nvvm.atomic.dec.gen.i.cta.i32.p0
550 // expected-error@+1 {{'__nvvm_atom_cta_dec_gen_ui' needs target feature sm_60}}
551 __nvvm_atom_cta_dec_gen_ui((unsigned int *)ip, i);
552 // CHECK: call i32 @llvm.nvvm.atomic.dec.gen.i.sys.i32.p0
553 // expected-error@+1 {{'__nvvm_atom_sys_dec_gen_ui' needs target feature sm_60}}
554 __nvvm_atom_sys_dec_gen_ui((unsigned int *)ip, i);
555
556 // CHECK: call i32 @llvm.nvvm.atomic.and.gen.i.cta.i32.p0
557 // expected-error@+1 {{'__nvvm_atom_cta_and_gen_i' needs target feature sm_60}}
558 __nvvm_atom_cta_and_gen_i(ip, i);
559 // LP32: call i32 @llvm.nvvm.atomic.and.gen.i.cta.i32.p0
560 // LP64: call i64 @llvm.nvvm.atomic.and.gen.i.cta.i64.p0
561 // expected-error@+1 {{'__nvvm_atom_cta_and_gen_l' needs target feature sm_60}}
562 __nvvm_atom_cta_and_gen_l(&dl, l);
563 // CHECK: call i64 @llvm.nvvm.atomic.and.gen.i.cta.i64.p0
564 // expected-error@+1 {{'__nvvm_atom_cta_and_gen_ll' needs target feature sm_60}}
565 __nvvm_atom_cta_and_gen_ll(&sll, ll);
566
567 // CHECK: call i32 @llvm.nvvm.atomic.and.gen.i.sys.i32.p0
568 // expected-error@+1 {{'__nvvm_atom_sys_and_gen_i' needs target feature sm_60}}
569 __nvvm_atom_sys_and_gen_i(ip, i);
570 // LP32: call i32 @llvm.nvvm.atomic.and.gen.i.sys.i32.p0
571 // LP64: call i64 @llvm.nvvm.atomic.and.gen.i.sys.i64.p0
572 // expected-error@+1 {{'__nvvm_atom_sys_and_gen_l' needs target feature sm_60}}
573 __nvvm_atom_sys_and_gen_l(&dl, l);
574 // CHECK: call i64 @llvm.nvvm.atomic.and.gen.i.sys.i64.p0
575 // expected-error@+1 {{'__nvvm_atom_sys_and_gen_ll' needs target feature sm_60}}
576 __nvvm_atom_sys_and_gen_ll(&sll, ll);
577
578 // CHECK: call i32 @llvm.nvvm.atomic.or.gen.i.cta.i32.p0
579 // expected-error@+1 {{'__nvvm_atom_cta_or_gen_i' needs target feature sm_60}}
580 __nvvm_atom_cta_or_gen_i(ip, i);
581 // LP32: call i32 @llvm.nvvm.atomic.or.gen.i.cta.i32.p0
582 // LP64: call i64 @llvm.nvvm.atomic.or.gen.i.cta.i64.p0
583 // expected-error@+1 {{'__nvvm_atom_cta_or_gen_l' needs target feature sm_60}}
584 __nvvm_atom_cta_or_gen_l(&dl, l);
585 // CHECK: call i64 @llvm.nvvm.atomic.or.gen.i.cta.i64.p0
586 // expected-error@+1 {{'__nvvm_atom_cta_or_gen_ll' needs target feature sm_60}}
587 __nvvm_atom_cta_or_gen_ll(&sll, ll);
588
589 // CHECK: call i32 @llvm.nvvm.atomic.or.gen.i.sys.i32.p0
590 // expected-error@+1 {{'__nvvm_atom_sys_or_gen_i' needs target feature sm_60}}
591 __nvvm_atom_sys_or_gen_i(ip, i);
592 // LP32: call i32 @llvm.nvvm.atomic.or.gen.i.sys.i32.p0
593 // LP64: call i64 @llvm.nvvm.atomic.or.gen.i.sys.i64.p0
594 // expected-error@+1 {{'__nvvm_atom_sys_or_gen_l' needs target feature sm_60}}
595 __nvvm_atom_sys_or_gen_l(&dl, l);
596 // CHECK: call i64 @llvm.nvvm.atomic.or.gen.i.sys.i64.p0
597 // expected-error@+1 {{'__nvvm_atom_sys_or_gen_ll' needs target feature sm_60}}
598 __nvvm_atom_sys_or_gen_ll(&sll, ll);
599
600 // CHECK: call i32 @llvm.nvvm.atomic.xor.gen.i.cta.i32.p0
601 // expected-error@+1 {{'__nvvm_atom_cta_xor_gen_i' needs target feature sm_60}}
602 __nvvm_atom_cta_xor_gen_i(ip, i);
603 // LP32: call i32 @llvm.nvvm.atomic.xor.gen.i.cta.i32.p0
604 // LP64: call i64 @llvm.nvvm.atomic.xor.gen.i.cta.i64.p0
605 // expected-error@+1 {{'__nvvm_atom_cta_xor_gen_l' needs target feature sm_60}}
606 __nvvm_atom_cta_xor_gen_l(&dl, l);
607 // CHECK: call i64 @llvm.nvvm.atomic.xor.gen.i.cta.i64.p0
608 // expected-error@+1 {{'__nvvm_atom_cta_xor_gen_ll' needs target feature sm_60}}
609 __nvvm_atom_cta_xor_gen_ll(&sll, ll);
610
611 // CHECK: call i32 @llvm.nvvm.atomic.xor.gen.i.sys.i32.p0
612 // expected-error@+1 {{'__nvvm_atom_sys_xor_gen_i' needs target feature sm_60}}
613 __nvvm_atom_sys_xor_gen_i(ip, i);
614 // LP32: call i32 @llvm.nvvm.atomic.xor.gen.i.sys.i32.p0
615 // LP64: call i64 @llvm.nvvm.atomic.xor.gen.i.sys.i64.p0
616 // expected-error@+1 {{'__nvvm_atom_sys_xor_gen_l' needs target feature sm_60}}
617 __nvvm_atom_sys_xor_gen_l(&dl, l);
618 // CHECK: call i64 @llvm.nvvm.atomic.xor.gen.i.sys.i64.p0
619 // expected-error@+1 {{'__nvvm_atom_sys_xor_gen_ll' needs target feature sm_60}}
620 __nvvm_atom_sys_xor_gen_ll(&sll, ll);
621
622 // CHECK: call i32 @llvm.nvvm.atomic.cas.gen.i.cta.i32.p0
623 // expected-error@+1 {{'__nvvm_atom_cta_cas_gen_i' needs target feature sm_60}}
624 __nvvm_atom_cta_cas_gen_i(ip, i, 0);
625 // LP32: call i32 @llvm.nvvm.atomic.cas.gen.i.cta.i32.p0
626 // LP64: call i64 @llvm.nvvm.atomic.cas.gen.i.cta.i64.p0
627 // expected-error@+1 {{'__nvvm_atom_cta_cas_gen_l' needs target feature sm_60}}
628 __nvvm_atom_cta_cas_gen_l(&dl, l, 0);
629 // CHECK: call i64 @llvm.nvvm.atomic.cas.gen.i.cta.i64.p0
630 // expected-error@+1 {{'__nvvm_atom_cta_cas_gen_ll' needs target feature sm_60}}
631 __nvvm_atom_cta_cas_gen_ll(&sll, ll, 0);
632
633 // CHECK: call i32 @llvm.nvvm.atomic.cas.gen.i.sys.i32.p0
634 // expected-error@+1 {{'__nvvm_atom_sys_cas_gen_i' needs target feature sm_60}}
635 __nvvm_atom_sys_cas_gen_i(ip, i, 0);
636 // LP32: call i32 @llvm.nvvm.atomic.cas.gen.i.sys.i32.p0
637 // LP64: call i64 @llvm.nvvm.atomic.cas.gen.i.sys.i64.p0
638 // expected-error@+1 {{'__nvvm_atom_sys_cas_gen_l' needs target feature sm_60}}
639 __nvvm_atom_sys_cas_gen_l(&dl, l, 0);
640 // CHECK: call i64 @llvm.nvvm.atomic.cas.gen.i.sys.i64.p0
641 // expected-error@+1 {{'__nvvm_atom_sys_cas_gen_ll' needs target feature sm_60}}
642 __nvvm_atom_sys_cas_gen_ll(&sll, ll, 0);
643 #endif
644
645 #if __CUDA_ARCH__ >= 700
646 // CHECK_PTX63_SM70: cmpxchg ptr {{.*}} seq_cst seq_cst, align 2
647 // CHECK_PTX63_SM70-NEXT: extractvalue { i16, i1 } {{%[0-9]+}}, 0
648 __nvvm_atom_cas_gen_us(usp, 0, us);
649 // CHECK_PTX63_SM70: call i16 @llvm.nvvm.atomic.cas.gen.i.cta.i16.p0
650 __nvvm_atom_cta_cas_gen_us(usp, 0, us);
651 // CHECK_PTX63_SM70: call i16 @llvm.nvvm.atomic.cas.gen.i.sys.i16.p0
652 __nvvm_atom_sys_cas_gen_us(usp, 0, us);
653 #endif
654
655 // CHECK: ret
656 }
657
658 // CHECK-LABEL: nvvm_ldg
659 __device__ void nvvm_ldg(const void *p) {
660 // CHECK: load i8, ptr addrspace(1) {{%[0-9]+}}, align 1, !invariant.load
661 // CHECK: load i8, ptr addrspace(1) {{%[0-9]+}}, align 1, !invariant.load
662 // CHECK: load i8, ptr addrspace(1) {{%[0-9]+}}, align 1, !invariant.load
663 __nvvm_ldg_c((const char *)p);
664 __nvvm_ldg_uc((const unsigned char *)p);
665 __nvvm_ldg_sc((const signed char *)p);
666
667 // CHECK: load i16, ptr addrspace(1) {{%[0-9]+}}, align 2, !invariant.load
668 // CHECK: load i16, ptr addrspace(1) {{%[0-9]+}}, align 2, !invariant.load
669 __nvvm_ldg_s((const short *)p);
670 __nvvm_ldg_us((const unsigned short *)p);
671
672 // CHECK: load i32, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
673 // CHECK: load i32, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
674 __nvvm_ldg_i((const int *)p);
675 __nvvm_ldg_ui((const unsigned int *)p);
676
677 // LP32: load i32, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
678 // LP32: load i32, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
679 // LP64: load i64, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
680 // LP64: load i64, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
681 __nvvm_ldg_l((const long *)p);
682 __nvvm_ldg_ul((const unsigned long *)p);
683
684 // CHECK: load float, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
685 __nvvm_ldg_f((const float *)p);
686 // CHECK: load double, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
687 __nvvm_ldg_d((const double *)p);
688
689 // In practice, the pointers we pass to __ldg will be aligned as appropriate
690 // for the CUDA <type>N vector types (e.g. short4), which are not the same as
691 // the LLVM vector types. However, each LLVM vector type has an alignment
692 // less than or equal to its corresponding CUDA type, so we're OK.
693 //
694 // PTX Interoperability section 2.2: "For a vector with an even number of
695 // elements, its alignment is set to number of elements times the alignment of
696 // its member: n*alignof(t)."
697
698 // CHECK: load <2 x i8>, ptr addrspace(1) {{%[0-9]+}}, align 2, !invariant.load
699 // CHECK: load <2 x i8>, ptr addrspace(1) {{%[0-9]+}}, align 2, !invariant.load
700 // CHECK: load <2 x i8>, ptr addrspace(1) {{%[0-9]+}}, align 2, !invariant.load
701 typedef char char2 __attribute__((ext_vector_type(2)));
702 typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
703 typedef signed char schar2 __attribute__((ext_vector_type(2)));
704 __nvvm_ldg_c2((const char2 *)p);
705 __nvvm_ldg_uc2((const uchar2 *)p);
706 __nvvm_ldg_sc2((const schar2 *)p);
707
708 // CHECK: load <4 x i8>, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
709 // CHECK: load <4 x i8>, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
710 // CHECK: load <4 x i8>, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
711 typedef char char4 __attribute__((ext_vector_type(4)));
712 typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
713 typedef signed char schar4 __attribute__((ext_vector_type(4)));
714 __nvvm_ldg_c4((const char4 *)p);
715 __nvvm_ldg_uc4((const uchar4 *)p);
716 __nvvm_ldg_sc4((const schar4 *)p);
717
718 // CHECK: load <2 x i16>, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
719 // CHECK: load <2 x i16>, ptr addrspace(1) {{%[0-9]+}}, align 4, !invariant.load
720 typedef short short2 __attribute__((ext_vector_type(2)));
721 typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
722 __nvvm_ldg_s2((const short2 *)p);
723 __nvvm_ldg_us2((const ushort2 *)p);
724
725 // CHECK: load <4 x i16>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
726 // CHECK: load <4 x i16>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
727 typedef short short4 __attribute__((ext_vector_type(4)));
728 typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
729 __nvvm_ldg_s4((const short4 *)p);
730 __nvvm_ldg_us4((const ushort4 *)p);
731
732 // CHECK: load <2 x i32>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
733 // CHECK: load <2 x i32>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
734 typedef int int2 __attribute__((ext_vector_type(2)));
735 typedef unsigned int uint2 __attribute__((ext_vector_type(2)));
736 __nvvm_ldg_i2((const int2 *)p);
737 __nvvm_ldg_ui2((const uint2 *)p);
738
739 // CHECK: load <4 x i32>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
740 // CHECK: load <4 x i32>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
741 typedef int int4 __attribute__((ext_vector_type(4)));
742 typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
743 __nvvm_ldg_i4((const int4 *)p);
744 __nvvm_ldg_ui4((const uint4 *)p);
745
746 // LP32: load <2 x i32>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
747 // LP32: load <2 x i32>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
748 // LP64: load <2 x i64>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
749 // LP64: load <2 x i64>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
750 typedef long long2 __attribute__((ext_vector_type(2)));
751 typedef unsigned long ulong2 __attribute__((ext_vector_type(2)));
752 __nvvm_ldg_l2((const long2 *)p);
753 __nvvm_ldg_ul2((const ulong2 *)p);
754
755 // CHECK: load <2 x i64>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
756 // CHECK: load <2 x i64>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
757 typedef long long longlong2 __attribute__((ext_vector_type(2)));
758 typedef unsigned long long ulonglong2 __attribute__((ext_vector_type(2)));
759 __nvvm_ldg_ll2((const longlong2 *)p);
760 __nvvm_ldg_ull2((const ulonglong2 *)p);
761
762 // CHECK: load <2 x float>, ptr addrspace(1) {{%[0-9]+}}, align 8, !invariant.load
763 typedef float float2 __attribute__((ext_vector_type(2)));
764 __nvvm_ldg_f2((const float2 *)p);
765
766 // CHECK: load <4 x float>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
767 typedef float float4 __attribute__((ext_vector_type(4)));
768 __nvvm_ldg_f4((const float4 *)p);
769
770 // CHECK: load <2 x double>, ptr addrspace(1) {{%[0-9]+}}, align 16, !invariant.load
771 typedef double double2 __attribute__((ext_vector_type(2)));
772 __nvvm_ldg_d2((const double2 *)p);
773 }
774
775 // CHECK-LABEL: nvvm_ldu
776 __device__ void nvvm_ldu(const void *p) {
777 // CHECK: call i8 @llvm.nvvm.ldu.global.i.i8.p0(ptr {{%[0-9]+}}, i32 1)
778 // CHECK: call i8 @llvm.nvvm.ldu.global.i.i8.p0(ptr {{%[0-9]+}}, i32 1)
779 // CHECK: call i8 @llvm.nvvm.ldu.global.i.i8.p0(ptr {{%[0-9]+}}, i32 1)
780 __nvvm_ldu_c((const char *)p);
781 __nvvm_ldu_uc((const unsigned char *)p);
782 __nvvm_ldu_sc((const signed char *)p);
783
784 // CHECK: call i16 @llvm.nvvm.ldu.global.i.i16.p0(ptr {{%[0-9]+}}, i32 2)
785 // CHECK: call i16 @llvm.nvvm.ldu.global.i.i16.p0(ptr {{%[0-9]+}}, i32 2)
786 __nvvm_ldu_s((const short *)p);
787 __nvvm_ldu_us((const unsigned short *)p);
788
789 // CHECK: call i32 @llvm.nvvm.ldu.global.i.i32.p0(ptr {{%[0-9]+}}, i32 4)
790 // CHECK: call i32 @llvm.nvvm.ldu.global.i.i32.p0(ptr {{%[0-9]+}}, i32 4)
791 __nvvm_ldu_i((const int *)p);
792 __nvvm_ldu_ui((const unsigned int *)p);
793
794 // LP32: call i32 @llvm.nvvm.ldu.global.i.i32.p0(ptr {{%[0-9]+}}, i32 4)
795 // LP32: call i32 @llvm.nvvm.ldu.global.i.i32.p0(ptr {{%[0-9]+}}, i32 4)
796 // LP64: call i64 @llvm.nvvm.ldu.global.i.i64.p0(ptr {{%[0-9]+}}, i32 8)
797 // LP64: call i64 @llvm.nvvm.ldu.global.i.i64.p0(ptr {{%[0-9]+}}, i32 8)
798 __nvvm_ldu_l((const long *)p);
799 __nvvm_ldu_ul((const unsigned long *)p);
800
801 // CHECK: call float @llvm.nvvm.ldu.global.f.f32.p0(ptr {{%[0-9]+}}, i32 4)
802 __nvvm_ldu_f((const float *)p);
803 // CHECK: call double @llvm.nvvm.ldu.global.f.f64.p0(ptr {{%[0-9]+}}, i32 8)
804 __nvvm_ldu_d((const double *)p);
805
806 // CHECK: call <2 x i8> @llvm.nvvm.ldu.global.i.v2i8.p0(ptr {{%[0-9]+}}, i32 2)
807 // CHECK: call <2 x i8> @llvm.nvvm.ldu.global.i.v2i8.p0(ptr {{%[0-9]+}}, i32 2)
808 // CHECK: call <2 x i8> @llvm.nvvm.ldu.global.i.v2i8.p0(ptr {{%[0-9]+}}, i32 2)
809 typedef char char2 __attribute__((ext_vector_type(2)));
810 typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
811 typedef signed char schar2 __attribute__((ext_vector_type(2)));
812 __nvvm_ldu_c2((const char2 *)p);
813 __nvvm_ldu_uc2((const uchar2 *)p);
814 __nvvm_ldu_sc2((const schar2 *)p);
815
816 // CHECK: call <4 x i8> @llvm.nvvm.ldu.global.i.v4i8.p0(ptr {{%[0-9]+}}, i32 4)
817 // CHECK: call <4 x i8> @llvm.nvvm.ldu.global.i.v4i8.p0(ptr {{%[0-9]+}}, i32 4)
818 // CHECK: call <4 x i8> @llvm.nvvm.ldu.global.i.v4i8.p0(ptr {{%[0-9]+}}, i32 4)
819 typedef char char4 __attribute__((ext_vector_type(4)));
820 typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
821 typedef signed char schar4 __attribute__((ext_vector_type(4)));
822 __nvvm_ldu_c4((const char4 *)p);
823 __nvvm_ldu_uc4((const uchar4 *)p);
824 __nvvm_ldu_sc4((const schar4 *)p);
825
826 // CHECK: call <2 x i16> @llvm.nvvm.ldu.global.i.v2i16.p0(ptr {{%[0-9]+}}, i32 4)
827 // CHECK: call <2 x i16> @llvm.nvvm.ldu.global.i.v2i16.p0(ptr {{%[0-9]+}}, i32 4)
828 typedef short short2 __attribute__((ext_vector_type(2)));
829 typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
830 __nvvm_ldu_s2((const short2 *)p);
831 __nvvm_ldu_us2((const ushort2 *)p);
832
833 // CHECK: call <4 x i16> @llvm.nvvm.ldu.global.i.v4i16.p0(ptr {{%[0-9]+}}, i32 8)
834 // CHECK: call <4 x i16> @llvm.nvvm.ldu.global.i.v4i16.p0(ptr {{%[0-9]+}}, i32 8)
835 typedef short short4 __attribute__((ext_vector_type(4)));
836 typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
837 __nvvm_ldu_s4((const short4 *)p);
838 __nvvm_ldu_us4((const ushort4 *)p);
839
840 // CHECK: call <2 x i32> @llvm.nvvm.ldu.global.i.v2i32.p0(ptr {{%[0-9]+}}, i32 8)
841 // CHECK: call <2 x i32> @llvm.nvvm.ldu.global.i.v2i32.p0(ptr {{%[0-9]+}}, i32 8)
842 typedef int int2 __attribute__((ext_vector_type(2)));
843 typedef unsigned int uint2 __attribute__((ext_vector_type(2)));
844 __nvvm_ldu_i2((const int2 *)p);
845 __nvvm_ldu_ui2((const uint2 *)p);
846
847 // CHECK: call <4 x i32> @llvm.nvvm.ldu.global.i.v4i32.p0(ptr {{%[0-9]+}}, i32 16)
848 // CHECK: call <4 x i32> @llvm.nvvm.ldu.global.i.v4i32.p0(ptr {{%[0-9]+}}, i32 16)
849 typedef int int4 __attribute__((ext_vector_type(4)));
850 typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
851 __nvvm_ldu_i4((const int4 *)p);
852 __nvvm_ldu_ui4((const uint4 *)p);
853
854 // LP32: call <2 x i32> @llvm.nvvm.ldu.global.i.v2i32.p0(ptr {{%[0-9]+}}, i32 8)
855 // LP32: call <2 x i32> @llvm.nvvm.ldu.global.i.v2i32.p0(ptr {{%[0-9]+}}, i32 8)
856 // LP64: call <2 x i64> @llvm.nvvm.ldu.global.i.v2i64.p0(ptr {{%[0-9]+}}, i32 16)
857 // LP64: call <2 x i64> @llvm.nvvm.ldu.global.i.v2i64.p0(ptr {{%[0-9]+}}, i32 16)
858 typedef long long2 __attribute__((ext_vector_type(2)));
859 typedef unsigned long ulong2 __attribute__((ext_vector_type(2)));
860 __nvvm_ldu_l2((const long2 *)p);
861 __nvvm_ldu_ul2((const ulong2 *)p);
862
863 // CHECK: call <2 x i64> @llvm.nvvm.ldu.global.i.v2i64.p0(ptr {{%[0-9]+}}, i32 16)
864 // CHECK: call <2 x i64> @llvm.nvvm.ldu.global.i.v2i64.p0(ptr {{%[0-9]+}}, i32 16)
865 typedef long long longlong2 __attribute__((ext_vector_type(2)));
866 typedef unsigned long long ulonglong2 __attribute__((ext_vector_type(2)));
867 __nvvm_ldu_ll2((const longlong2 *)p);
868 __nvvm_ldu_ull2((const ulonglong2 *)p);
869
870 // CHECK: call <2 x float> @llvm.nvvm.ldu.global.f.v2f32.p0(ptr {{%[0-9]+}}, i32 8)
871 typedef float float2 __attribute__((ext_vector_type(2)));
872 __nvvm_ldu_f2((const float2 *)p);
873
874 // CHECK: call <4 x float> @llvm.nvvm.ldu.global.f.v4f32.p0(ptr {{%[0-9]+}}, i32 16)
875 typedef float float4 __attribute__((ext_vector_type(4)));
876 __nvvm_ldu_f4((const float4 *)p);
877
878 // CHECK: call <2 x double> @llvm.nvvm.ldu.global.f.v2f64.p0(ptr {{%[0-9]+}}, i32 16)
879 typedef double double2 __attribute__((ext_vector_type(2)));
880 __nvvm_ldu_d2((const double2 *)p);
881 }
882
883 // CHECK-LABEL: nvvm_shfl
884 __device__ void nvvm_shfl(int i, float f, int a, int b) {
885 // CHECK: call i32 @llvm.nvvm.shfl.down.i32(i32
886 __nvvm_shfl_down_i32(i, a, b);
887 // CHECK: call float @llvm.nvvm.shfl.down.f32(float
888 __nvvm_shfl_down_f32(f, a, b);
889 // CHECK: call i32 @llvm.nvvm.shfl.up.i32(i32
890 __nvvm_shfl_up_i32(i, a, b);
891 // CHECK: call float @llvm.nvvm.shfl.up.f32(float
892 __nvvm_shfl_up_f32(f, a, b);
893 // CHECK: call i32 @llvm.nvvm.shfl.bfly.i32(i32
894 __nvvm_shfl_bfly_i32(i, a, b);
895 // CHECK: call float @llvm.nvvm.shfl.bfly.f32(float
896 __nvvm_shfl_bfly_f32(f, a, b);
897 // CHECK: call i32 @llvm.nvvm.shfl.idx.i32(i32
898 __nvvm_shfl_idx_i32(i, a, b);
899 // CHECK: call float @llvm.nvvm.shfl.idx.f32(float
900 __nvvm_shfl_idx_f32(f, a, b);
901 // CHECK: ret void
902 }
903
904 __device__ void nvvm_vote(int pred) {
905 // CHECK: call i1 @llvm.nvvm.vote.all(i1
906 __nvvm_vote_all(pred);
907 // CHECK: call i1 @llvm.nvvm.vote.any(i1
908 __nvvm_vote_any(pred);
909 // CHECK: call i1 @llvm.nvvm.vote.uni(i1
910 __nvvm_vote_uni(pred);
911 // CHECK: call i32 @llvm.nvvm.vote.ballot(i1
912 __nvvm_vote_ballot(pred);
913 // CHECK: ret void
914 }
915
916 // CHECK-LABEL: nvvm_pm_event_mask
917 __device__ void nvvm_pm_event_mask() {
918 // CHECK: call void @llvm.nvvm.pm.event.mask(i16 255)
919 __nvvm_pm_event_mask(255);
920 // CHECK: ret void
921 }
922
923 // CHECK-LABEL: nvvm_nanosleep
924 __device__ void nvvm_nanosleep(int d) {
925 #if __CUDA_ARCH__ >= 700
926 // CHECK_PTX70_SM80: call void @llvm.nvvm.nanosleep
927 __nvvm_nanosleep(d);
928
929 // CHECK_PTX70_SM80: call void @llvm.nvvm.nanosleep
930 __nvvm_nanosleep(1);
931 #endif
932 }
933
934 // CHECK-LABEL: nvvm_mbarrier
935 __device__ void nvvm_mbarrier(long long* addr, __attribute__((address_space(3))) long long* sharedAddr, int count, long long state) {
936 #if __CUDA_ARCH__ >= 800
937 __nvvm_mbarrier_init(addr, count);
938 // CHECK_PTX70_SM80: call void @llvm.nvvm.mbarrier.init
939 __nvvm_mbarrier_init_shared(sharedAddr, count);
940 // CHECK_PTX70_SM80: call void @llvm.nvvm.mbarrier.init.shared
941
942 __nvvm_mbarrier_inval(addr);
943 // CHECK_PTX70_SM80: call void @llvm.nvvm.mbarrier.inval
944 __nvvm_mbarrier_inval_shared(sharedAddr);
945 // CHECK_PTX70_SM80: call void @llvm.nvvm.mbarrier.inval.shared
946
947 __nvvm_mbarrier_arrive(addr);
948 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive
949 __nvvm_mbarrier_arrive_shared(sharedAddr);
950 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.shared
951 __nvvm_mbarrier_arrive_noComplete(addr, count);
952 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.noComplete
953 __nvvm_mbarrier_arrive_noComplete_shared(sharedAddr, count);
954 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.noComplete.shared
955
956 __nvvm_mbarrier_arrive_drop(addr);
957 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.drop
958 __nvvm_mbarrier_arrive_drop_shared(sharedAddr);
959 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.drop.shared
960 __nvvm_mbarrier_arrive_drop_noComplete(addr, count);
961 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.drop.noComplete
962 __nvvm_mbarrier_arrive_drop_noComplete_shared(sharedAddr, count);
963 // CHECK_PTX70_SM80: call i64 @llvm.nvvm.mbarrier.arrive.drop.noComplete.shared
964
965 __nvvm_mbarrier_test_wait(addr, state);
966 // CHECK_PTX70_SM80: call i1 @llvm.nvvm.mbarrier.test.wait
967 __nvvm_mbarrier_test_wait_shared(sharedAddr, state);
968 // CHECK_PTX70_SM80: call i1 @llvm.nvvm.mbarrier.test.wait.shared
969
970 __nvvm_mbarrier_pending_count(state);
971 // CHECK_PTX70_SM80: call i32 @llvm.nvvm.mbarrier.pending.count
972 #endif
973 // CHECK: ret void
974 }
975
976 // CHECK-LABEL: nvvm_async_copy
977 __device__ void nvvm_async_copy(__attribute__((address_space(3))) void* dst, __attribute__((address_space(1))) const void* src, long long* addr, __attribute__((address_space(3))) long long* sharedAddr) {
978 #if __CUDA_ARCH__ >= 800
979 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.mbarrier.arrive
980 __nvvm_cp_async_mbarrier_arrive(addr);
981 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.mbarrier.arrive.shared
982 __nvvm_cp_async_mbarrier_arrive_shared(sharedAddr);
983 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc
984 __nvvm_cp_async_mbarrier_arrive_noinc(addr);
985 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc.shared
986 __nvvm_cp_async_mbarrier_arrive_noinc_shared(sharedAddr);
987
988 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.ca.shared.global.4(
989 __nvvm_cp_async_ca_shared_global_4(dst, src);
990 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.ca.shared.global.8(
991 __nvvm_cp_async_ca_shared_global_8(dst, src);
992 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.ca.shared.global.16(
993 __nvvm_cp_async_ca_shared_global_16(dst, src);
994 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.cg.shared.global.16(
995 __nvvm_cp_async_cg_shared_global_16(dst, src);
996
997 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.ca.shared.global.4.s({{.*}}, i32 2)
998 __nvvm_cp_async_ca_shared_global_4(dst, src, 2);
999 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.ca.shared.global.8.s({{.*}}, i32 2)
1000 __nvvm_cp_async_ca_shared_global_8(dst, src, 2);
1001 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.ca.shared.global.16.s({{.*}}, i32 2)
1002 __nvvm_cp_async_ca_shared_global_16(dst, src, 2);
1003 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.cg.shared.global.16.s({{.*}}, i32 2)
1004 __nvvm_cp_async_cg_shared_global_16(dst, src, 2);
1005
1006 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.commit.group
1007 __nvvm_cp_async_commit_group();
1008 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.wait.group(i32 0)
1009 __nvvm_cp_async_wait_group(0);
1010 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.wait.group(i32 8)
1011 __nvvm_cp_async_wait_group(8);
1012 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.wait.group(i32 16)
1013 __nvvm_cp_async_wait_group(16);
1014 // CHECK_PTX70_SM80: call void @llvm.nvvm.cp.async.wait.all
1015 __nvvm_cp_async_wait_all();
1016 #endif
1017 // CHECK: ret void
1018 }
1019
1020 // CHECK-LABEL: nvvm_cvt_sm80
1021 __device__ void nvvm_cvt_sm80() {
1022 #if __CUDA_ARCH__ >= 800
1023 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rn(float 1.000000e+00, float 1.000000e+00)
1024 __nvvm_ff2bf16x2_rn(1, 1);
1025 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rn.relu(float 1.000000e+00, float 1.000000e+00)
1026 __nvvm_ff2bf16x2_rn_relu(1, 1);
1027 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rz(float 1.000000e+00, float 1.000000e+00)
1028 __nvvm_ff2bf16x2_rz(1, 1);
1029 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rz.relu(float 1.000000e+00, float 1.000000e+00)
1030 __nvvm_ff2bf16x2_rz_relu(1, 1);
1031 #if PTX >= 81
1032 // CHECK_PTX81_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1033 __nvvm_ff2bf16x2_rn_satfinite(1, 1);
1034 // CHECK_PTX81_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1035 __nvvm_ff2bf16x2_rn_relu_satfinite(1, 1);
1036 // CHECK_PTX81_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rz.satfinite(float 1.000000e+00, float 1.000000e+00)
1037 __nvvm_ff2bf16x2_rz_satfinite(1, 1);
1038 // CHECK_PTX81_SM80: call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rz.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1039 __nvvm_ff2bf16x2_rz_relu_satfinite(1, 1);
1040 #endif
1041
1042 // CHECK_PTX70_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rn(float 1.000000e+00, float 1.000000e+00)
1043 __nvvm_ff2f16x2_rn(1, 1);
1044 // CHECK_PTX70_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rn.relu(float 1.000000e+00, float 1.000000e+00)
1045 __nvvm_ff2f16x2_rn_relu(1, 1);
1046 // CHECK_PTX70_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rz(float 1.000000e+00, float 1.000000e+00)
1047 __nvvm_ff2f16x2_rz(1, 1);
1048 // CHECK_PTX70_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rz.relu(float 1.000000e+00, float 1.000000e+00)
1049 __nvvm_ff2f16x2_rz_relu(1, 1);
1050 #if PTX >= 81
1051 // CHECK_PTX81_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1052 __nvvm_ff2f16x2_rn_satfinite(1, 1);
1053 // CHECK_PTX81_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1054 __nvvm_ff2f16x2_rn_relu_satfinite(1, 1);
1055 // CHECK_PTX81_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rz.satfinite(float 1.000000e+00, float 1.000000e+00)
1056 __nvvm_ff2f16x2_rz_satfinite(1, 1);
1057 // CHECK_PTX81_SM80: call <2 x half> @llvm.nvvm.ff2f16x2.rz.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1058 __nvvm_ff2f16x2_rz_relu_satfinite(1, 1);
1059 #endif
1060
1061 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.f2bf16.rn(float 1.000000e+00)
1062 __nvvm_f2bf16_rn(1);
1063 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.f2bf16.rn.relu(float 1.000000e+00)
1064 __nvvm_f2bf16_rn_relu(1);
1065 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.f2bf16.rz(float 1.000000e+00)
1066 __nvvm_f2bf16_rz(1);
1067 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.f2bf16.rz.relu(float 1.000000e+00)
1068 __nvvm_f2bf16_rz_relu(1);
1069 #if PTX >= 81
1070 // CHECK_PTX81_SM80: call bfloat @llvm.nvvm.f2bf16.rn.satfinite(float 1.000000e+00)
1071 __nvvm_f2bf16_rn_satfinite(1);
1072 // CHECK_PTX81_SM80: call bfloat @llvm.nvvm.f2bf16.rn.relu.satfinite(float 1.000000e+00)
1073 __nvvm_f2bf16_rn_relu_satfinite(1);
1074 // CHECK_PTX81_SM80: call bfloat @llvm.nvvm.f2bf16.rz.satfinite(float 1.000000e+00)
1075 __nvvm_f2bf16_rz_satfinite(1);
1076 // CHECK_PTX81_SM80: call bfloat @llvm.nvvm.f2bf16.rz.relu.satfinite(float 1.000000e+00)
1077 __nvvm_f2bf16_rz_relu_satfinite(1);
1078 #endif
1079
1080 // CHECK_PTX70_SM80: call half @llvm.nvvm.f2f16.rn(float 1.000000e+00)
1081 __nvvm_f2f16_rn(1);
1082 // CHECK_PTX70_SM80: call half @llvm.nvvm.f2f16.rn.relu(float 1.000000e+00)
1083 __nvvm_f2f16_rn_relu(1);
1084 // CHECK_PTX70_SM80: call half @llvm.nvvm.f2f16.rz(float 1.000000e+00)
1085 __nvvm_f2f16_rz(1);
1086 // CHECK_PTX70_SM80: call half @llvm.nvvm.f2f16.rz.relu(float 1.000000e+00)
1087 __nvvm_f2f16_rz_relu(1);
1088 #if PTX >= 81
1089 // CHECK_PTX81_SM80: call half @llvm.nvvm.f2f16.rn.satfinite(float 1.000000e+00)
1090 __nvvm_f2f16_rn_satfinite(1);
1091 // CHECK_PTX81_SM80: call half @llvm.nvvm.f2f16.rn.relu.satfinite(float 1.000000e+00)
1092 __nvvm_f2f16_rn_relu_satfinite(1);
1093 // CHECK_PTX81_SM80: call half @llvm.nvvm.f2f16.rz.satfinite(float 1.000000e+00)
1094 __nvvm_f2f16_rz_satfinite(1);
1095 // CHECK_PTX81_SM80: call half @llvm.nvvm.f2f16.rz.relu.satfinite(float 1.000000e+00)
1096 __nvvm_f2f16_rz_relu_satfinite(1);
1097 #endif
1098
1099 // CHECK_PTX70_SM80: call i32 @llvm.nvvm.f2tf32.rna(float 1.000000e+00)
1100 __nvvm_f2tf32_rna(1);
1101 #if PTX >= 81
1102 // CHECK_PTX81_SM80: call i32 @llvm.nvvm.f2tf32.rna.satfinite(float 1.000000e+00)
1103 __nvvm_f2tf32_rna_satfinite(1.0f);
1104 #endif
1105 #endif
1106 // CHECK: ret void
1107 }
1108
1109 // CHECK-LABEL: nvvm_cvt_sm89
1110 __device__ void nvvm_cvt_sm89() {
1111 #if (PTX >= 81) && (__CUDA_ARCH__ >= 890)
1112 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.ff.to.e4m3x2.rn(float 1.000000e+00, float 1.000000e+00)
1113 __nvvm_ff_to_e4m3x2_rn(1.0f, 1.0f);
1114 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.ff.to.e4m3x2.rn.relu(float 1.000000e+00, float 1.000000e+00)
1115 __nvvm_ff_to_e4m3x2_rn_relu(1.0f, 1.0f);
1116 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.ff.to.e5m2x2.rn(float 1.000000e+00, float 1.000000e+00)
1117 __nvvm_ff_to_e5m2x2_rn(1.0f, 1.0f);
1118 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.ff.to.e5m2x2.rn.relu(float 1.000000e+00, float 1.000000e+00)
1119 __nvvm_ff_to_e5m2x2_rn_relu(1.0f, 1.0f);
1120
1121 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.f16x2.to.e4m3x2.rn(<2 x half> splat (half 0xH3C00))
1122 __nvvm_f16x2_to_e4m3x2_rn({1.0f16, 1.0f16});
1123 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.f16x2.to.e4m3x2.rn.relu(<2 x half> splat (half 0xH3C00))
1124 __nvvm_f16x2_to_e4m3x2_rn_relu({1.0f16, 1.0f16});
1125 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.f16x2.to.e5m2x2.rn(<2 x half> splat (half 0xH3C00))
1126 __nvvm_f16x2_to_e5m2x2_rn({1.0f16, 1.0f16});
1127 // CHECK_PTX81_SM89: call i16 @llvm.nvvm.f16x2.to.e5m2x2.rn.relu(<2 x half> splat (half 0xH3C00))
1128 __nvvm_f16x2_to_e5m2x2_rn_relu({1.0f16, 1.0f16});
1129
1130 // CHECK_PTX81_SM89: call <2 x half> @llvm.nvvm.e4m3x2.to.f16x2.rn(i16 18504)
1131 __nvvm_e4m3x2_to_f16x2_rn(0x4848);
1132 // CHECK_PTX81_SM89: call <2 x half> @llvm.nvvm.e4m3x2.to.f16x2.rn.relu(i16 18504)
1133 __nvvm_e4m3x2_to_f16x2_rn_relu(0x4848);
1134 // CHECK_PTX81_SM89: call <2 x half> @llvm.nvvm.e5m2x2.to.f16x2.rn(i16 19532)
1135 __nvvm_e5m2x2_to_f16x2_rn(0x4c4c);
1136 // CHECK_PTX81_SM89: call <2 x half> @llvm.nvvm.e5m2x2.to.f16x2.rn.relu(i16 19532)
1137 __nvvm_e5m2x2_to_f16x2_rn_relu(0x4c4c);
1138 #endif
1139 // CHECK: ret void
1140 }
1141
1142 // CHECK-LABEL: nvvm_cvt_sm90
1143 __device__ void nvvm_cvt_sm90() {
1144 #if (PTX >= 78) && (__CUDA_ARCH__ >= 900)
1145 // CHECK_PTX78_SM90: call i32 @llvm.nvvm.f2tf32.rn(float 1.000000e+00)
1146 __nvvm_f2tf32_rn(1.0f);
1147 // CHECK_PTX78_SM90: call i32 @llvm.nvvm.f2tf32.rn.relu(float 1.000000e+00)
1148 __nvvm_f2tf32_rn_relu(1.0f);
1149 // CHECK_PTX78_SM90: call i32 @llvm.nvvm.f2tf32.rz(float 1.000000e+00)
1150 __nvvm_f2tf32_rz(1.0f);
1151 // CHECK_PTX78_SM90: call i32 @llvm.nvvm.f2tf32.rz.relu(float 1.000000e+00)
1152 __nvvm_f2tf32_rz_relu(1.0f);
1153 #endif
1154 // CHECK: ret void
1155 }
1156
1157 // CHECK-LABEL: nvvm_cvt_sm100
1158 __device__ void nvvm_cvt_sm100() {
1159 #if (PTX >= 86) && (__CUDA_ARCH__ >= 1000)
1160 // CHECK_PTX86_SM100: call i32 @llvm.nvvm.f2tf32.rn.satfinite(float 1.000000e+00)
1161 __nvvm_f2tf32_rn_satfinite(1.0f);
1162 // CHECK_PTX86_SM100: call i32 @llvm.nvvm.f2tf32.rn.relu.satfinite(float 1.000000e+00)
1163 __nvvm_f2tf32_rn_relu_satfinite(1.0f);
1164 // CHECK_PTX86_SM100: call i32 @llvm.nvvm.f2tf32.rz.satfinite(float 1.000000e+00)
1165 __nvvm_f2tf32_rz_satfinite(1.0f);
1166 // CHECK_PTX86_SM100: call i32 @llvm.nvvm.f2tf32.rz.relu.satfinite(float 1.000000e+00)
1167 __nvvm_f2tf32_rz_relu_satfinite(1.0f);
1168 #endif
1169 // CHECK: ret void
1170 }
1171
1172 // CHECK-LABEL: nvvm_cvt_sm100a_sm101a_sm120a
1173 __device__ void nvvm_cvt_sm100a_sm101a_sm120a() {
1174 #if (PTX >= 86) && \
1175 (__CUDA_ARCH_FEAT_SM100_ALL || __CUDA_ARCH_FEAT_SM101_ALL || \
1176 __CUDA_ARCH_FEAT_SM120_ALL)
1177 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.e2m3x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1178 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.e2m3x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1179 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.e2m3x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1180 __nvvm_ff_to_e2m3x2_rn_satfinite(1.0f, 1.0f);
1181
1182 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.e2m3x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1183 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.e2m3x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1184 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.e2m3x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1185 __nvvm_ff_to_e2m3x2_rn_relu_satfinite(1.0f, 1.0f);
1186
1187 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.e3m2x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1188 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.e3m2x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1189 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.e3m2x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1190 __nvvm_ff_to_e3m2x2_rn_satfinite(1.0f, 1.0f);
1191
1192 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.e3m2x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1193 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.e3m2x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1194 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.e3m2x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1195 __nvvm_ff_to_e3m2x2_rn_relu_satfinite(1.0f, 1.0f);
1196
1197 // CHECK_PTX86_SM100a: call <2 x half> @llvm.nvvm.e2m3x2.to.f16x2.rn(i16 19532)
1198 // CHECK_PTX86_SM101a: call <2 x half> @llvm.nvvm.e2m3x2.to.f16x2.rn(i16 19532)
1199 // CHECK_PTX86_SM120a: call <2 x half> @llvm.nvvm.e2m3x2.to.f16x2.rn(i16 19532)
1200 __nvvm_e2m3x2_to_f16x2_rn(0x4C4C);
1201
1202 // CHECK_PTX86_SM100a: call <2 x half> @llvm.nvvm.e2m3x2.to.f16x2.rn.relu(i16 18504)
1203 // CHECK_PTX86_SM101a: call <2 x half> @llvm.nvvm.e2m3x2.to.f16x2.rn.relu(i16 18504)
1204 // CHECK_PTX86_SM120a: call <2 x half> @llvm.nvvm.e2m3x2.to.f16x2.rn.relu(i16 18504)
1205 __nvvm_e2m3x2_to_f16x2_rn_relu(0x4848);
1206
1207 // CHECK_PTX86_SM100a: call <2 x half> @llvm.nvvm.e3m2x2.to.f16x2.rn(i16 18504)
1208 // CHECK_PTX86_SM101a: call <2 x half> @llvm.nvvm.e3m2x2.to.f16x2.rn(i16 18504)
1209 // CHECK_PTX86_SM120a: call <2 x half> @llvm.nvvm.e3m2x2.to.f16x2.rn(i16 18504)
1210 __nvvm_e3m2x2_to_f16x2_rn(0x4848);
1211
1212 // CHECK_PTX86_SM100a: call <2 x half> @llvm.nvvm.e3m2x2.to.f16x2.rn.relu(i16 19532)
1213 // CHECK_PTX86_SM101a: call <2 x half> @llvm.nvvm.e3m2x2.to.f16x2.rn.relu(i16 19532)
1214 // CHECK_PTX86_SM120a: call <2 x half> @llvm.nvvm.e3m2x2.to.f16x2.rn.relu(i16 19532)
1215 __nvvm_e3m2x2_to_f16x2_rn_relu(0x4C4C);
1216
1217 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.e2m1x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1218 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.e2m1x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1219 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.e2m1x2.rn.satfinite(float 1.000000e+00, float 1.000000e+00)
1220 __nvvm_ff_to_e2m1x2_rn_satfinite(1.0f, 1.0f);
1221
1222 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.e2m1x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1223 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.e2m1x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1224 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.e2m1x2.rn.relu.satfinite(float 1.000000e+00, float 1.000000e+00)
1225 __nvvm_ff_to_e2m1x2_rn_relu_satfinite(1.0f, 1.0f);
1226
1227 // CHECK_PTX86_SM100a: call <2 x half> @llvm.nvvm.e2m1x2.to.f16x2.rn(i16 76)
1228 // CHECK_PTX86_SM101a: call <2 x half> @llvm.nvvm.e2m1x2.to.f16x2.rn(i16 76)
1229 // CHECK_PTX86_SM120a: call <2 x half> @llvm.nvvm.e2m1x2.to.f16x2.rn(i16 76)
1230 __nvvm_e2m1x2_to_f16x2_rn(0x004C);
1231
1232 // CHECK_PTX86_SM100a: call <2 x half> @llvm.nvvm.e2m1x2.to.f16x2.rn.relu(i16 76)
1233 // CHECK_PTX86_SM101a: call <2 x half> @llvm.nvvm.e2m1x2.to.f16x2.rn.relu(i16 76)
1234 // CHECK_PTX86_SM120a: call <2 x half> @llvm.nvvm.e2m1x2.to.f16x2.rn.relu(i16 76)
1235 __nvvm_e2m1x2_to_f16x2_rn_relu(0x004C);
1236
1237 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rz(float 1.000000e+00, float 1.000000e+00)
1238 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rz(float 1.000000e+00, float 1.000000e+00)
1239 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rz(float 1.000000e+00, float 1.000000e+00)
1240 __nvvm_ff_to_ue8m0x2_rz(1.0f, 1.0f);
1241
1242 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rz.satfinite(float 1.000000e+00, float 1.000000e+00)
1243 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rz.satfinite(float 1.000000e+00, float 1.000000e+00)
1244 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rz.satfinite(float 1.000000e+00, float 1.000000e+00)
1245 __nvvm_ff_to_ue8m0x2_rz_satfinite(1.0f, 1.0f);
1246
1247 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rp(float 1.000000e+00, float 1.000000e+00)
1248 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rp(float 1.000000e+00, float 1.000000e+00)
1249 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rp(float 1.000000e+00, float 1.000000e+00)
1250 __nvvm_ff_to_ue8m0x2_rp(1.0f, 1.0f);
1251
1252 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rp.satfinite(float 1.000000e+00, float 1.000000e+00)
1253 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rp.satfinite(float 1.000000e+00, float 1.000000e+00)
1254 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.ff.to.ue8m0x2.rp.satfinite(float 1.000000e+00, float 1.000000e+00)
1255 __nvvm_ff_to_ue8m0x2_rp_satfinite(1.0f, 1.0f);
1256
1257 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz(<2 x bfloat> splat (bfloat 0xR3DCD)
1258 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz(<2 x bfloat> splat (bfloat 0xR3DCD)
1259 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz(<2 x bfloat> splat (bfloat 0xR3DCD)
1260 __nvvm_bf16x2_to_ue8m0x2_rz({(__bf16)0.1f, (__bf16)0.1f});
1261
1262 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz.satfinite(<2 x bfloat> splat (bfloat 0xR3DCD)
1263 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz.satfinite(<2 x bfloat> splat (bfloat 0xR3DCD)
1264 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rz.satfinite(<2 x bfloat> splat (bfloat 0xR3DCD)
1265 __nvvm_bf16x2_to_ue8m0x2_rz_satfinite({(__bf16)0.1f, (__bf16)0.1f});
1266
1267 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp(<2 x bfloat> splat (bfloat 0xR3DCD)
1268 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp(<2 x bfloat> splat (bfloat 0xR3DCD)
1269 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp(<2 x bfloat> splat (bfloat 0xR3DCD)
1270 __nvvm_bf16x2_to_ue8m0x2_rp({(__bf16)0.1f, (__bf16)0.1f});
1271
1272 // CHECK_PTX86_SM100a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp.satfinite(<2 x bfloat> splat (bfloat 0xR3DCD)
1273 // CHECK_PTX86_SM101a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp.satfinite(<2 x bfloat> splat (bfloat 0xR3DCD)
1274 // CHECK_PTX86_SM120a: call i16 @llvm.nvvm.bf16x2.to.ue8m0x2.rp.satfinite(<2 x bfloat> splat (bfloat 0xR3DCD)
1275 __nvvm_bf16x2_to_ue8m0x2_rp_satfinite({(__bf16)0.1f, (__bf16)0.1f});
1276
1277 // CHECK_PTX86_SM100a: call <2 x bfloat> @llvm.nvvm.ue8m0x2.to.bf16x2(i16 19532)
1278 // CHECK_PTX86_SM101a: call <2 x bfloat> @llvm.nvvm.ue8m0x2.to.bf16x2(i16 19532)
1279 // CHECK_PTX86_SM120a: call <2 x bfloat> @llvm.nvvm.ue8m0x2.to.bf16x2(i16 19532)
1280 __nvvm_ue8m0x2_to_bf16x2(0x4C4C);
1281
1282 #endif
1283 // CHECK: ret void
1284 }
1285
1286 __device__ void nvvm_cvt_sm100a_sm103a() {
1287 #if (PTX >= 87) && (__CUDA_ARCH_FEAT_SM100_ALL || __CUDA_ARCH_FEAT_SM103_ALL)
1288
1289 typedef __fp16 f16x2 __attribute__((ext_vector_type(2)));
1290 typedef __bf16 bf16x2 __attribute__((ext_vector_type(2)));
1291 typedef char uint8x4 __attribute__((ext_vector_type(4)));
1292
1293 // CHECK_PTX87_SM100a: %[[R1:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs(float 1.000000e+00, float 1.000000e+00, i32 0)
1294 // CHECK_PTX87_SM100a: store <2 x half> %[[R1]], ptr %r1
1295 // CHECK_PTX87_SM103a: %[[R1:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs(float 1.000000e+00, float 1.000000e+00, i32 0)
1296 // CHECK_PTX87_SM103a: store <2 x half> %[[R1]], ptr %r1
1297 f16x2 r1 = __nvvm_ff2f16x2_rs(1.0f, 1.0f, 0);
1298
1299 // CHECK_PTX87_SM100a: %[[R2:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs.relu(float 1.000000e+00, float 1.000000e+00, i32 0)
1300 // CHECK_PTX87_SM100a: store <2 x half> %[[R2]], ptr %r2
1301 // CHECK_PTX87_SM103a: %[[R2:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs.relu(float 1.000000e+00, float 1.000000e+00, i32 0)
1302 // CHECK_PTX87_SM103a: store <2 x half> %[[R2]], ptr %r2
1303 f16x2 r2 = __nvvm_ff2f16x2_rs_relu(1.0f, 1.0f, 0);
1304
1305 // CHECK_PTX87_SM100a: %[[R3:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1306 // CHECK_PTX87_SM100a: store <2 x half> %[[R3]], ptr %r3
1307 // CHECK_PTX87_SM103a: %[[R3:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1308 // CHECK_PTX87_SM103a: store <2 x half> %[[R3]], ptr %r3
1309 f16x2 r3 = __nvvm_ff2f16x2_rs_satfinite(1.0f, 1.0f, 0);
1310
1311 // CHECK_PTX87_SM100a: %[[R4:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs.relu.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1312 // CHECK_PTX87_SM100a: store <2 x half> %[[R4]], ptr %r4
1313 // CHECK_PTX87_SM103a: %[[R4:.*]] = call <2 x half> @llvm.nvvm.ff2f16x2.rs.relu.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1314 // CHECK_PTX87_SM103a: store <2 x half> %[[R4]], ptr %r4
1315 f16x2 r4 = __nvvm_ff2f16x2_rs_relu_satfinite(1.0f, 1.0f, 0);
1316
1317 // CHECK_PTX87_SM100a: %[[R5:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs(float 1.000000e+00, float 1.000000e+00, i32 0)
1318 // CHECK_PTX87_SM100a: store <2 x bfloat> %[[R5]], ptr %r5
1319 // CHECK_PTX87_SM103a: %[[R5:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs(float 1.000000e+00, float 1.000000e+00, i32 0)
1320 // CHECK_PTX87_SM103a: store <2 x bfloat> %[[R5]], ptr %r5
1321 bf16x2 r5 = __nvvm_ff2bf16x2_rs(1.0f, 1.0f, 0);
1322
1323 // CHECK_PTX87_SM100a: %[[R6:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs.relu(float 1.000000e+00, float 1.000000e+00, i32 0)
1324 // CHECK_PTX87_SM100a: store <2 x bfloat> %[[R6]], ptr %r6
1325 // CHECK_PTX87_SM103a: %[[R6:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs.relu(float 1.000000e+00, float 1.000000e+00, i32 0)
1326 // CHECK_PTX87_SM103a: store <2 x bfloat> %[[R6]], ptr %r6
1327 bf16x2 r6 = __nvvm_ff2bf16x2_rs_relu(1.0f, 1.0f, 0);
1328
1329 // CHECK_PTX87_SM100a: %[[R7:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1330 // CHECK_PTX87_SM100a: store <2 x bfloat> %[[R7]], ptr %r7
1331 // CHECK_PTX87_SM103a: %[[R7:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1332 // CHECK_PTX87_SM103a: store <2 x bfloat> %[[R7]], ptr %r7
1333 bf16x2 r7 = __nvvm_ff2bf16x2_rs_satfinite(1.0f, 1.0f, 0);
1334
1335 // CHECK_PTX87_SM100a: %[[R8:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs.relu.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1336 // CHECK_PTX87_SM100a: store <2 x bfloat> %[[R8]], ptr %r8
1337 // CHECK_PTX87_SM103a: %[[R8:.*]] = call <2 x bfloat> @llvm.nvvm.ff2bf16x2.rs.relu.satfinite(float 1.000000e+00, float 1.000000e+00, i32 0)
1338 // CHECK_PTX87_SM103a: store <2 x bfloat> %[[R8]], ptr %r8
1339 bf16x2 r8 = __nvvm_ff2bf16x2_rs_relu_satfinite(1.0f, 1.0f, 0);
1340
1341 // CHECK_PTX87_SM100a: %[[R9:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e4m3x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1342 // CHECK_PTX87_SM100a: store <4 x i8> %[[R9]], ptr %r9
1343 // CHECK_PTX87_SM103a: %[[R9:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e4m3x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1344 // CHECK_PTX87_SM103a: store <4 x i8> %[[R9]], ptr %r9
1345 uint8x4 r9 = __nvvm_f32x4_to_e4m3x4_rs_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1346
1347 // CHECK_PTX87_SM100a: %[[R10:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e4m3x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1348 // CHECK_PTX87_SM100a: store <4 x i8> %[[R10]], ptr %r10
1349 // CHECK_PTX87_SM103a: %[[R10:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e4m3x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1350 // CHECK_PTX87_SM103a: store <4 x i8> %[[R10]], ptr %r10
1351 uint8x4 r10 = __nvvm_f32x4_to_e4m3x4_rs_relu_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1352
1353 // CHECK_PTX87_SM100a: %[[R11:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e5m2x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1354 // CHECK_PTX87_SM100a: store <4 x i8> %[[R11]], ptr %r11
1355 // CHECK_PTX87_SM103a: %[[R11:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e5m2x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1356 // CHECK_PTX87_SM103a: store <4 x i8> %[[R11]], ptr %r11
1357 uint8x4 r11 = __nvvm_f32x4_to_e5m2x4_rs_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1358
1359 // CHECK_PTX87_SM100a: %[[R12:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e5m2x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1360 // CHECK_PTX87_SM100a: store <4 x i8> %[[R12]], ptr %r12
1361 // CHECK_PTX87_SM103a: %[[R12:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e5m2x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1362 // CHECK_PTX87_SM103a: store <4 x i8> %[[R12]], ptr %r12
1363 uint8x4 r12 = __nvvm_f32x4_to_e5m2x4_rs_relu_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1364
1365 // CHECK_PTX87_SM100a: %[[R13:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e2m3x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1366 // CHECK_PTX87_SM100a: store <4 x i8> %[[R13]], ptr %r13
1367 // CHECK_PTX87_SM103a: %[[R13:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e2m3x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1368 // CHECK_PTX87_SM103a: store <4 x i8> %[[R13]], ptr %r13
1369 uint8x4 r13 = __nvvm_f32x4_to_e2m3x4_rs_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1370
1371 // CHECK_PTX87_SM100a: %[[R14:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e2m3x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1372 // CHECK_PTX87_SM100a: store <4 x i8> %[[R14]], ptr %r14
1373 // CHECK_PTX87_SM103a: %[[R14:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e2m3x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1374 // CHECK_PTX87_SM103a: store <4 x i8> %[[R14]], ptr %r14
1375 uint8x4 r14 = __nvvm_f32x4_to_e2m3x4_rs_relu_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1376
1377 // CHECK_PTX87_SM100a: %[[R15:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e3m2x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1378 // CHECK_PTX87_SM100a: store <4 x i8> %[[R15]], ptr %r15
1379 // CHECK_PTX87_SM103a: %[[R15:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e3m2x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1380 // CHECK_PTX87_SM103a: store <4 x i8> %[[R15]], ptr %r15
1381 uint8x4 r15 = __nvvm_f32x4_to_e3m2x4_rs_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1382
1383 // CHECK_PTX87_SM100a: %[[R16:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e3m2x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1384 // CHECK_PTX87_SM100a: store <4 x i8> %[[R16]], ptr %r16
1385 // CHECK_PTX87_SM103a: %[[R16:.*]] = call <4 x i8> @llvm.nvvm.f32x4.to.e3m2x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1386 // CHECK_PTX87_SM103a: store <4 x i8> %[[R16]], ptr %r16
1387 uint8x4 r16 = __nvvm_f32x4_to_e3m2x4_rs_relu_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1388
1389 // CHECK_PTX87_SM100a: %[[R17:.*]] = call i16 @llvm.nvvm.f32x4.to.e2m1x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1390 // CHECK_PTX87_SM100a: store i16 %[[R17]], ptr %r17
1391 // CHECK_PTX87_SM103a: %[[R17:.*]] = call i16 @llvm.nvvm.f32x4.to.e2m1x4.rs.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1392 // CHECK_PTX87_SM103a: store i16 %[[R17]], ptr %r17
1393 short r17 = __nvvm_f32x4_to_e2m1x4_rs_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1394
1395 // CHECK_PTX87_SM100a: %[[R18:.*]] = call i16 @llvm.nvvm.f32x4.to.e2m1x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1396 // CHECK_PTX87_SM100a: store i16 %[[R18]], ptr %r18
1397 // CHECK_PTX87_SM103a: %[[R18:.*]] = call i16 @llvm.nvvm.f32x4.to.e2m1x4.rs.relu.satfinite(<4 x float> splat (float 1.000000e+00), i32 0)
1398 // CHECK_PTX87_SM103a: store i16 %[[R18]], ptr %r18
1399 short r18 = __nvvm_f32x4_to_e2m1x4_rs_relu_satfinite({1.0f, 1.0f, 1.0f, 1.0f}, 0);
1400 #endif
1401 }
1402
1403 #define NAN32 0x7FBFFFFF
1404 #define NAN16 (__bf16)0x7FBF
1405 #define BF16 (__bf16)0.1f
1406 #define BF16_2 (__bf16)0.2f
1407 #define NANBF16 (__bf16)0xFFC1
1408 #define BF16X2 {(__bf16)0.1f, (__bf16)0.1f}
1409 #define BF16X2_2 {(__bf16)0.2f, (__bf16)0.2f}
1410 #define NANBF16X2 {NANBF16, NANBF16}
1411
1412 // CHECK-LABEL: nvvm_abs_neg_bf16_bf16x2_sm80
1413 __device__ void nvvm_abs_neg_bf16_bf16x2_sm80() {
1414 #if __CUDA_ARCH__ >= 800
1415
1416 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fabs.bf16(bfloat 0xR3DCD)
1417 __nvvm_abs_bf16(BF16);
1418 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fabs.v2bf16(<2 x bfloat> splat (bfloat 0xR3DCD))
1419 __nvvm_abs_bf16x2(BF16X2);
1420
1421 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.neg.bf16(bfloat 0xR3DCD)
1422 __nvvm_neg_bf16(BF16);
1423 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.neg.bf16x2(<2 x bfloat> splat (bfloat 0xR3DCD))
1424 __nvvm_neg_bf16x2(BF16X2);
1425 #endif
1426 // CHECK: ret void
1427 }
1428
1429 // CHECK-LABEL: nvvm_min_max_sm80
1430 __device__ void nvvm_min_max_sm80() {
1431 #if __CUDA_ARCH__ >= 800
1432
1433 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmin.nan.f
1434 __nvvm_fmin_nan_f(0.1f, (float)NAN32);
1435 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmin.ftz.nan.f
1436 __nvvm_fmin_ftz_nan_f(0.1f, (float)NAN32);
1437
1438 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmin.bf16
1439 __nvvm_fmin_bf16(BF16, BF16_2);
1440 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmin.ftz.bf16
1441 __nvvm_fmin_ftz_bf16(BF16, BF16_2);
1442 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmin.nan.bf16
1443 __nvvm_fmin_nan_bf16(BF16, NANBF16);
1444 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmin.ftz.nan.bf16
1445 __nvvm_fmin_ftz_nan_bf16(BF16, NANBF16);
1446 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmin.bf16x2
1447 __nvvm_fmin_bf16x2(BF16X2, BF16X2_2);
1448 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmin.ftz.bf16x2
1449 __nvvm_fmin_ftz_bf16x2(BF16X2, BF16X2_2);
1450 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmin.nan.bf16x2
1451 __nvvm_fmin_nan_bf16x2(BF16X2, NANBF16X2);
1452 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmin.ftz.nan.bf16x2
1453 __nvvm_fmin_ftz_nan_bf16x2(BF16X2, NANBF16X2);
1454 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmax.nan.f
1455 __nvvm_fmax_nan_f(0.1f, 0.11f);
1456 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmax.ftz.nan.f
1457 __nvvm_fmax_ftz_nan_f(0.1f, (float)NAN32);
1458
1459 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmax.nan.f
1460 __nvvm_fmax_nan_f(0.1f, (float)NAN32);
1461 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmax.ftz.nan.f
1462 __nvvm_fmax_ftz_nan_f(0.1f, (float)NAN32);
1463 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmax.bf16
1464 __nvvm_fmax_bf16(BF16, BF16_2);
1465 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmax.ftz.bf16
1466 __nvvm_fmax_ftz_bf16(BF16, BF16_2);
1467 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmax.nan.bf16
1468 __nvvm_fmax_nan_bf16(BF16, NANBF16);
1469 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fmax.ftz.nan.bf16
1470 __nvvm_fmax_ftz_nan_bf16(BF16, NANBF16);
1471 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmax.bf16x2
1472 __nvvm_fmax_bf16x2(BF16X2, BF16X2_2);
1473 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmax.ftz.bf16x2
1474 __nvvm_fmax_ftz_bf16x2(BF16X2, BF16X2_2);
1475 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmax.nan.bf16x2
1476 __nvvm_fmax_nan_bf16x2(NANBF16X2, BF16X2);
1477 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fmax.ftz.nan.bf16x2
1478 __nvvm_fmax_ftz_nan_bf16x2(NANBF16X2, BF16X2);
1479 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmax.nan.f
1480 __nvvm_fmax_nan_f(0.1f, (float)NAN32);
1481 // CHECK_PTX70_SM80: call float @llvm.nvvm.fmax.ftz.nan.f
1482 __nvvm_fmax_ftz_nan_f(0.1f, (float)NAN32);
1483
1484 #endif
1485 // CHECK: ret void
1486 }
1487
1488 // CHECK-LABEL: nvvm_fma_bf16_bf16x2_sm80
1489 __device__ void nvvm_fma_bf16_bf16x2_sm80() {
1490 #if __CUDA_ARCH__ >= 800
1491 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fma.rn.bf16
1492 __nvvm_fma_rn_bf16(BF16, BF16_2, BF16_2);
1493 // CHECK_PTX70_SM80: call bfloat @llvm.nvvm.fma.rn.relu.bf16
1494 __nvvm_fma_rn_relu_bf16(BF16, BF16_2, BF16_2);
1495 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fma.rn.bf16x2
1496 __nvvm_fma_rn_bf16x2(BF16X2, BF16X2_2, BF16X2_2);
1497 // CHECK_PTX70_SM80: call <2 x bfloat> @llvm.nvvm.fma.rn.relu.bf16x2
1498 __nvvm_fma_rn_relu_bf16x2(BF16X2, BF16X2_2, BF16X2_2);
1499 #endif
1500 // CHECK: ret void
1501 }
1502
1503 // CHECK-LABEL: nvvm_min_max_sm86
1504 __device__ void nvvm_min_max_sm86() {
1505 #if __CUDA_ARCH__ >= 860
1506
1507 // CHECK_PTX72_SM86: call bfloat @llvm.nvvm.fmin.xorsign.abs.bf16
1508 __nvvm_fmin_xorsign_abs_bf16(BF16, BF16_2);
1509 // CHECK_PTX72_SM86: call bfloat @llvm.nvvm.fmin.nan.xorsign.abs.bf16
1510 __nvvm_fmin_nan_xorsign_abs_bf16(BF16, NANBF16);
1511 // CHECK_PTX72_SM86: call <2 x bfloat> @llvm.nvvm.fmin.xorsign.abs.bf16x2
1512 __nvvm_fmin_xorsign_abs_bf16x2(BF16X2, BF16X2_2);
1513 // CHECK_PTX72_SM86: call <2 x bfloat> @llvm.nvvm.fmin.nan.xorsign.abs.bf16x2
1514 __nvvm_fmin_nan_xorsign_abs_bf16x2(BF16X2, NANBF16X2);
1515 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmin.xorsign.abs.f
1516 __nvvm_fmin_xorsign_abs_f(-0.1f, 0.1f);
1517 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmin.ftz.xorsign.abs.f
1518 __nvvm_fmin_ftz_xorsign_abs_f(-0.1f, 0.1f);
1519 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmin.nan.xorsign.abs.f
1520 __nvvm_fmin_nan_xorsign_abs_f(-0.1f, (float)NAN32);
1521 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmin.ftz.nan.xorsign.abs.f
1522 __nvvm_fmin_ftz_nan_xorsign_abs_f(-0.1f, (float)NAN32);
1523
1524 // CHECK_PTX72_SM86: call bfloat @llvm.nvvm.fmax.xorsign.abs.bf16
1525 __nvvm_fmax_xorsign_abs_bf16(BF16, BF16_2);
1526 // CHECK_PTX72_SM86: call bfloat @llvm.nvvm.fmax.nan.xorsign.abs.bf16
1527 __nvvm_fmax_nan_xorsign_abs_bf16(BF16, NANBF16);
1528 // CHECK_PTX72_SM86: call <2 x bfloat> @llvm.nvvm.fmax.xorsign.abs.bf16x2
1529 __nvvm_fmax_xorsign_abs_bf16x2(BF16X2, BF16X2_2);
1530 // CHECK_PTX72_SM86: call <2 x bfloat> @llvm.nvvm.fmax.nan.xorsign.abs.bf16x2
1531 __nvvm_fmax_nan_xorsign_abs_bf16x2(BF16X2, NANBF16X2);
1532 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmax.xorsign.abs.f
1533 __nvvm_fmax_xorsign_abs_f(-0.1f, 0.1f);
1534 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmax.ftz.xorsign.abs.f
1535 __nvvm_fmax_ftz_xorsign_abs_f(-0.1f, 0.1f);
1536 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmax.nan.xorsign.abs.f
1537 __nvvm_fmax_nan_xorsign_abs_f(-0.1f, (float)NAN32);
1538 // CHECK_PTX72_SM86: call float @llvm.nvvm.fmax.ftz.nan.xorsign.abs.f
1539 __nvvm_fmax_ftz_nan_xorsign_abs_f(-0.1f, (float)NAN32);
1540 #endif
1541 // CHECK: ret void
1542 }
1543
1544 // CHECK-LABEL: nvvm_add_fma_f32_sat
1545 __device__ void nvvm_add_fma_f32_sat() {
1546 // CHECK: call float @llvm.nvvm.add.rn.sat.f
1547 __nvvm_add_rn_sat_f(1.0f, 2.0f);
1548 // CHECK: call float @llvm.nvvm.add.rn.ftz.sat.f
1549 __nvvm_add_rn_ftz_sat_f(1.0f, 2.0f);
1550 // CHECK: call float @llvm.nvvm.add.rz.sat.f
1551 __nvvm_add_rz_sat_f(1.0f, 2.0f);
1552 // CHECK: call float @llvm.nvvm.add.rz.ftz.sat.f
1553 __nvvm_add_rz_ftz_sat_f(1.0f, 2.0f);
1554 // CHECK: call float @llvm.nvvm.add.rm.sat.f
1555 __nvvm_add_rm_sat_f(1.0f, 2.0f);
1556 // CHECK: call float @llvm.nvvm.add.rm.ftz.sat.f
1557 __nvvm_add_rm_ftz_sat_f(1.0f, 2.0f);
1558 // CHECK: call float @llvm.nvvm.add.rp.sat.f
1559 __nvvm_add_rp_sat_f(1.0f, 2.0f);
1560 // CHECK: call float @llvm.nvvm.add.rp.ftz.sat.f
1561 __nvvm_add_rp_ftz_sat_f(1.0f, 2.0f);
1562
1563 // CHECK: call float @llvm.nvvm.fma.rn.sat.f
1564 __nvvm_fma_rn_sat_f(1.0f, 2.0f, 3.0f);
1565 // CHECK: call float @llvm.nvvm.fma.rn.ftz.sat.f
1566 __nvvm_fma_rn_ftz_sat_f(1.0f, 2.0f, 3.0f);
1567 // CHECK: call float @llvm.nvvm.fma.rz.sat.f
1568 __nvvm_fma_rz_sat_f(1.0f, 2.0f, 3.0f);
1569 // CHECK: call float @llvm.nvvm.fma.rz.ftz.sat.f
1570 __nvvm_fma_rz_ftz_sat_f(1.0f, 2.0f, 3.0f);
1571 // CHECK: call float @llvm.nvvm.fma.rm.sat.f
1572 __nvvm_fma_rm_sat_f(1.0f, 2.0f, 3.0f);
1573 // CHECK: call float @llvm.nvvm.fma.rm.ftz.sat.f
1574 __nvvm_fma_rm_ftz_sat_f(1.0f, 2.0f, 3.0f);
1575 // CHECK: call float @llvm.nvvm.fma.rp.sat.f
1576 __nvvm_fma_rp_sat_f(1.0f, 2.0f, 3.0f);
1577 // CHECK: call float @llvm.nvvm.fma.rp.ftz.sat.f
1578 __nvvm_fma_rp_ftz_sat_f(1.0f, 2.0f, 3.0f);
1579
1580 // CHECK: ret void
1581 }