1 // REQUIRES
: amdgpu-registered-target
2 // RUN
: %clang_cc1 -cl-std
=CL2.0 -triple amdgcn-unknown-unknown -target-cpu tahiti -S -emit-llvm -o - %s | FileCheck -enable-var-scope %s
4 #pragma OPENCL EXTENSION cl_khr_fp64
: enable
6 typedef unsigned long ulong
;
7 typedef unsigned int uint
;
8 typedef unsigned short ushort
;
9 typedef half __attribute__
((ext_vector_type(2))) half2
;
10 typedef short __attribute__
((ext_vector_type(2))) short2
;
11 typedef ushort __attribute__
((ext_vector_type(2))) ushort2
;
12 typedef uint __attribute__
((ext_vector_type(4))) uint4
;
14 // CHECK-LABEL
: @test_div_scale_f64
15 // CHECK
: call
{ double
, i1
} @llvm.amdgcn.div.scale.f64
(double %a
, double %b
, i1 true
)
16 // CHECK-DAG
: [[FLAG
:%.
+]] = extractvalue
{ double
, i1
} %
{{.
+}}, 1
17 // CHECK-DAG
: [[VAL
:%.
+]] = extractvalue
{ double
, i1
} %
{{.
+}}, 0
18 // CHECK
: [[FLAGEXT
:%.
+]] = zext i1
[[FLAG]] to i32
19 // CHECK: store i32 [[FLAGEXT]]
20 void test_div_scale_f64(global double* out, global int* flagout, double a, double b)
23 *out = __builtin_amdgcn_div_scale(a, b, true, &flag);
27 // CHECK-LABEL: @test_div_scale_f32(
28 // CHECK: call { float, i1 } @llvm.amdgcn.div.scale.f32(float %a, float %b, i1 true)
29 // CHECK-DAG: [[FLAG:%.+]] = extractvalue { float, i1 } %{{.+}}, 1
30 // CHECK-DAG: [[VAL:%.+]] = extractvalue { float, i1 } %{{.+}}, 0
31 // CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i8
32 // CHECK
: store i8
[[FLAGEXT]]
33 void test_div_scale_f32(global float* out, global bool* flagout, float a, float b)
36 *out = __builtin_amdgcn_div_scalef(a, b, true, &flag);
40 // CHECK-LABEL: @test_div_scale_f32_global_ptr(
41 // CHECK: call { float, i1 } @llvm.amdgcn.div.scale.f32(float %a, float %b, i1 true)
42 // CHECK-DAG: [[FLAG:%.+]] = extractvalue { float, i1 } %{{.+}}, 1
43 // CHECK-DAG: [[VAL:%.+]] = extractvalue { float, i1 } %{{.+}}, 0
44 // CHECK: [[FLAGEXT:%.+]] = zext i1 [[FLAG]] to i8
45 // CHECK: store i8 [[FLAGEXT]]
46 void test_div_scale_f32_global_ptr
(global float
* out
, global int
* flagout
, float a
, float b
, global bool
* flag
)
48 *out
= __builtin_amdgcn_div_scalef
(a, b
, true
, flag
);
51 // CHECK-LABEL
: @test_div_scale_f32_generic_ptr
(
52 // CHECK
: call
{ float
, i1
} @llvm.amdgcn.div.scale.f32
(float %a
, float %b
, i1 true
)
53 // CHECK-DAG
: [[FLAG
:%.
+]] = extractvalue
{ float
, i1
} %
{{.
+}}, 1
54 // CHECK-DAG
: [[VAL
:%.
+]] = extractvalue
{ float
, i1
} %
{{.
+}}, 0
55 // CHECK
: [[FLAGEXT
:%.
+]] = zext i1
[[FLAG]] to i8
56 // CHECK: store i8 [[FLAGEXT]]
57 void test_div_scale_f32_generic_ptr(global float* out, global int* flagout, float a, float b, global bool* flag_arg)
59 generic bool* flag = flag_arg;
60 *out = __builtin_amdgcn_div_scalef(a, b, true, flag);
63 // CHECK-LABEL: @test_div_fmas_f32
64 // CHECK: call float @llvm.amdgcn.div.fmas.f32
65 void test_div_fmas_f32(global float* out, float a, float b, float c, int d)
67 *out = __builtin_amdgcn_div_fmasf(a, b, c, d);
70 // CHECK-LABEL: @test_div_fmas_f64
71 // CHECK: call double @llvm.amdgcn.div.fmas.f64
72 void test_div_fmas_f64(global double* out, double a, double b, double c, int d)
74 *out = __builtin_amdgcn_div_fmas(a, b, c, d);
77 // CHECK-LABEL: @test_div_fixup_f32
78 // CHECK: call float @llvm.amdgcn.div.fixup.f32
79 void test_div_fixup_f32(global float* out, float a, float b, float c)
81 *out = __builtin_amdgcn_div_fixupf(a, b, c);
84 // CHECK-LABEL: @test_div_fixup_f64
85 // CHECK: call double @llvm.amdgcn.div.fixup.f64
86 void test_div_fixup_f64(global double* out, double a, double b, double c)
88 *out = __builtin_amdgcn_div_fixup(a, b, c);
91 // CHECK-LABEL: @test_trig_preop_f32
92 // CHECK: call float @llvm.amdgcn.trig.preop.f32
93 void test_trig_preop_f32(global float* out, float a, int b)
95 *out = __builtin_amdgcn_trig_preopf(a, b);
98 // CHECK-LABEL: @test_trig_preop_f64
99 // CHECK: call double @llvm.amdgcn.trig.preop.f64
100 void test_trig_preop_f64(global double* out, double a, int b)
102 *out = __builtin_amdgcn_trig_preop(a, b);
105 // CHECK-LABEL: @test_rcp_f32
106 // CHECK: call float @llvm.amdgcn.rcp.f32
107 void test_rcp_f32(global float* out, float a)
109 *out = __builtin_amdgcn_rcpf(a);
112 // CHECK-LABEL: @test_rcp_f64
113 // CHECK: call double @llvm.amdgcn.rcp.f64
114 void test_rcp_f64(global double* out, double a)
116 *out = __builtin_amdgcn_rcp(a);
119 // CHECK-LABEL: @test_sqrt_f32
120 // CHECK: call float @llvm.amdgcn.sqrt.f32
121 void test_sqrt_f32(global float* out, float a)
123 *out = __builtin_amdgcn_sqrtf(a);
126 // CHECK-LABEL: @test_sqrt_f64
127 // CHECK: call double @llvm.amdgcn.sqrt.f64
128 void test_sqrt_f64(global double* out, double a)
130 *out = __builtin_amdgcn_sqrt(a);
133 // CHECK-LABEL: @test_rsq_f32
134 // CHECK: call float @llvm.amdgcn.rsq.f32
135 void test_rsq_f32(global float* out, float a)
137 *out = __builtin_amdgcn_rsqf(a);
140 // CHECK-LABEL: @test_rsq_f64
141 // CHECK: call double @llvm.amdgcn.rsq.f64
142 void test_rsq_f64(global double* out, double a)
144 *out = __builtin_amdgcn_rsq(a);
147 // CHECK-LABEL: @test_rsq_clamp_f32
148 // CHECK: call float @llvm.amdgcn.rsq.clamp.f32
149 void test_rsq_clamp_f32(global float* out, float a)
151 *out = __builtin_amdgcn_rsq_clampf(a);
154 // CHECK-LABEL: @test_rsq_clamp_f64
155 // CHECK: call double @llvm.amdgcn.rsq.clamp.f64
156 void test_rsq_clamp_f64(global double* out, double a)
158 *out = __builtin_amdgcn_rsq_clamp(a);
161 // CHECK-LABEL: @test_sin_f32
162 // CHECK: call float @llvm.amdgcn.sin.f32
163 void test_sin_f32(global float* out, float a)
165 *out = __builtin_amdgcn_sinf(a);
168 // CHECK-LABEL: @test_cos_f32
169 // CHECK: call float @llvm.amdgcn.cos.f32
170 void test_cos_f32(global float* out, float a)
172 *out = __builtin_amdgcn_cosf(a);
175 // CHECK-LABEL: @test_log_clamp_f32
176 // CHECK: call float @llvm.amdgcn.log.clamp.f32
177 void test_log_clamp_f32(global float* out, float a)
179 *out = __builtin_amdgcn_log_clampf(a);
182 // CHECK-LABEL: @test_ldexp_f32
183 // CHECK: call float @llvm.amdgcn.ldexp.f32
184 void test_ldexp_f32(global float* out, float a, int b)
186 *out = __builtin_amdgcn_ldexpf(a, b);
189 // CHECK-LABEL: @test_ldexp_f64
190 // CHECK: call double @llvm.amdgcn.ldexp.f64
191 void test_ldexp_f64(global double* out, double a, int b)
193 *out = __builtin_amdgcn_ldexp(a, b);
196 // CHECK-LABEL: @test_frexp_mant_f32
197 // CHECK: call float @llvm.amdgcn.frexp.mant.f32
198 void test_frexp_mant_f32(global float* out, float a)
200 *out = __builtin_amdgcn_frexp_mantf(a);
203 // CHECK-LABEL: @test_frexp_mant_f64
204 // CHECK: call double @llvm.amdgcn.frexp.mant.f64
205 void test_frexp_mant_f64(global double* out, double a)
207 *out = __builtin_amdgcn_frexp_mant(a);
210 // CHECK-LABEL: @test_frexp_exp_f32
211 // CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f32
212 void test_frexp_exp_f32(global int* out, float a)
214 *out = __builtin_amdgcn_frexp_expf(a);
217 // CHECK-LABEL: @test_frexp_exp_f64
218 // CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f64
219 void test_frexp_exp_f64(global int* out, double a)
221 *out = __builtin_amdgcn_frexp_exp(a);
224 // CHECK-LABEL: @test_fract_f32
225 // CHECK: call float @llvm.amdgcn.fract.f32
226 void test_fract_f32(global int* out, float a)
228 *out = __builtin_amdgcn_fractf(a);
231 // CHECK-LABEL: @test_fract_f64
232 // CHECK: call double @llvm.amdgcn.fract.f64
233 void test_fract_f64(global int* out, double a)
235 *out = __builtin_amdgcn_fract(a);
238 // CHECK-LABEL: @test_lerp
239 // CHECK: call i32 @llvm.amdgcn.lerp
240 void test_lerp(global int* out, int a, int b, int c)
242 *out = __builtin_amdgcn_lerp(a, b, c);
245 // CHECK-LABEL: @test_sicmp_i32
246 // CHECK: call i64 @llvm.amdgcn.icmp.i64.i32(i32 %a, i32 %b, i32 32)
247 void test_sicmp_i32(global ulong* out, int a, int b)
249 *out = __builtin_amdgcn_sicmp(a, b, 32);
252 // CHECK-LABEL: @test_uicmp_i32
253 // CHECK: call i64 @llvm.amdgcn.icmp.i64.i32(i32 %a, i32 %b, i32 32)
254 void test_uicmp_i32(global ulong* out, uint a, uint b)
256 *out = __builtin_amdgcn_uicmp(a, b, 32);
259 // CHECK-LABEL: @test_sicmp_i64
260 // CHECK: call i64 @llvm.amdgcn.icmp.i64.i64(i64 %a, i64 %b, i32 38)
261 void test_sicmp_i64(global ulong* out, long a, long b)
263 *out = __builtin_amdgcn_sicmpl(a, b, 39-1);
266 // CHECK-LABEL: @test_uicmp_i64
267 // CHECK: call i64 @llvm.amdgcn.icmp.i64.i64(i64 %a, i64 %b, i32 35)
268 void test_uicmp_i64(global ulong* out, ulong a, ulong b)
270 *out = __builtin_amdgcn_uicmpl(a, b, 30+5);
273 // CHECK-LABEL: @test_ds_swizzle
274 // CHECK: call i32 @llvm.amdgcn.ds.swizzle(i32 %a, i32 32)
275 void test_ds_swizzle(global int* out, int a)
277 *out = __builtin_amdgcn_ds_swizzle(a, 32);
280 // CHECK-LABEL: @test_ds_permute
281 // CHECK: call i32 @llvm.amdgcn.ds.permute(i32 %a, i32 %b)
282 void test_ds_permute(global int* out, int a, int b)
284 out[0] = __builtin_amdgcn_ds_permute(a, b);
287 // CHECK-LABEL: @test_ds_bpermute
288 // CHECK: call i32 @llvm.amdgcn.ds.bpermute(i32 %a, i32 %b)
289 void test_ds_bpermute(global int* out, int a, int b)
291 *out = __builtin_amdgcn_ds_bpermute(a, b);
294 // CHECK-LABEL: @test_readfirstlane
295 // CHECK: call i32 @llvm.amdgcn.readfirstlane(i32 %a)
296 void test_readfirstlane(global int* out, int a)
298 *out = __builtin_amdgcn_readfirstlane(a);
301 // CHECK-LABEL: @test_readlane
302 // CHECK: call i32 @llvm.amdgcn.readlane(i32 %a, i32 %b)
303 void test_readlane(global int* out, int a, int b)
305 *out = __builtin_amdgcn_readlane(a, b);
308 // CHECK-LABEL: @test_fcmp_f32
309 // CHECK: call i64 @llvm.amdgcn.fcmp.i64.f32(float %a, float %b, i32 5)
310 void test_fcmp_f32(global ulong* out, float a, float b)
312 *out = __builtin_amdgcn_fcmpf(a, b, 5);
315 // CHECK-LABEL: @test_fcmp_f64
316 // CHECK: call i64 @llvm.amdgcn.fcmp.i64.f64(double %a, double %b, i32 6)
317 void test_fcmp_f64(global ulong* out, double a, double b)
319 *out = __builtin_amdgcn_fcmp(a, b, 3+3);
322 // CHECK-LABEL: @test_class_f32
323 // CHECK: call i1 @llvm.amdgcn.class.f32
324 void test_class_f32(global float* out, float a, int b)
326 *out = __builtin_amdgcn_classf(a, b);
329 // CHECK-LABEL: @test_class_f64
330 // CHECK: call i1 @llvm.amdgcn.class.f64
331 void test_class_f64(global double* out, double a, int b)
333 *out = __builtin_amdgcn_class(a, b);
336 // CHECK-LABEL: @test_buffer_wbinvl1
337 // CHECK: call void @llvm.amdgcn.buffer.wbinvl1(
338 void test_buffer_wbinvl1()
340 __builtin_amdgcn_buffer_wbinvl1();
343 // CHECK-LABEL: @test_s_dcache_inv
344 // CHECK: call void @llvm.amdgcn.s.dcache.inv(
345 void test_s_dcache_inv()
347 __builtin_amdgcn_s_dcache_inv();
350 // CHECK-LABEL: @test_s_waitcnt
351 // CHECK: call void @llvm.amdgcn.s.waitcnt(
352 void test_s_waitcnt()
354 __builtin_amdgcn_s_waitcnt(0);
357 // CHECK-LABEL: @test_s_sendmsg
358 // CHECK: call void @llvm.amdgcn.s.sendmsg(
359 void test_s_sendmsg()
361 __builtin_amdgcn_s_sendmsg(1, 0);
364 // CHECK-LABEL: @test_s_sendmsg_var
365 // CHECK: call void @llvm.amdgcn.s.sendmsg(
366 void test_s_sendmsg_var(int in)
368 __builtin_amdgcn_s_sendmsg(1, in);
371 // CHECK-LABEL: @test_s_sendmsghalt
372 // CHECK: call void @llvm.amdgcn.s.sendmsghalt(
373 void test_s_sendmsghalt()
375 __builtin_amdgcn_s_sendmsghalt(1, 0);
378 // CHECK-LABEL: @test_s_sendmsghalt
379 // CHECK: call void @llvm.amdgcn.s.sendmsghalt(
380 void test_s_sendmsghalt_var(int in)
382 __builtin_amdgcn_s_sendmsghalt(1, in);
385 // CHECK-LABEL: @test_s_barrier
386 // CHECK: call void @llvm.amdgcn.s.barrier(
387 void test_s_barrier()
389 __builtin_amdgcn_s_barrier();
392 // CHECK-LABEL: @test_wave_barrier
393 // CHECK: call void @llvm.amdgcn.wave.barrier(
394 void test_wave_barrier()
396 __builtin_amdgcn_wave_barrier();
399 // CHECK-LABEL: @test_sched_barrier
400 // CHECK: call void @llvm.amdgcn.sched.barrier(i32 0)
401 // CHECK: call void @llvm.amdgcn.sched.barrier(i32 1)
402 // CHECK: call void @llvm.amdgcn.sched.barrier(i32 4)
403 // CHECK: call void @llvm.amdgcn.sched.barrier(i32 15)
404 void test_sched_barrier()
406 __builtin_amdgcn_sched_barrier(0);
407 __builtin_amdgcn_sched_barrier(1);
408 __builtin_amdgcn_sched_barrier(4);
409 __builtin_amdgcn_sched_barrier(15);
412 // CHECK-LABEL: @test_sched_group_barrier
413 // CHECK: call void @llvm.amdgcn.sched.group.barrier(i32 0, i32 1, i32 2)
414 // CHECK: call void @llvm.amdgcn.sched.group.barrier(i32 1, i32 2, i32 4)
415 // CHECK: call void @llvm.amdgcn.sched.group.barrier(i32 4, i32 8, i32 16)
416 // CHECK: call void @llvm.amdgcn.sched.group.barrier(i32 15, i32 10000, i32 -1)
417 void test_sched_group_barrier()
419 __builtin_amdgcn_sched_group_barrier(0, 1, 2);
420 __builtin_amdgcn_sched_group_barrier(1, 2, 4);
421 __builtin_amdgcn_sched_group_barrier(4, 8, 16);
422 __builtin_amdgcn_sched_group_barrier(15, 10000, -1);
425 // CHECK-LABEL: @test_iglp_opt
426 // CHECK: call void @llvm.amdgcn.iglp.opt(i32 0)
427 // CHECK: call void @llvm.amdgcn.iglp.opt(i32 1)
428 // CHECK: call void @llvm.amdgcn.iglp.opt(i32 4)
429 // CHECK: call void @llvm.amdgcn.iglp.opt(i32 15)
432 __builtin_amdgcn_iglp_opt(0);
433 __builtin_amdgcn_iglp_opt(1);
434 __builtin_amdgcn_iglp_opt(4);
435 __builtin_amdgcn_iglp_opt(15);
438 // CHECK-LABEL: @test_s_sleep
439 // CHECK: call void @llvm.amdgcn.s.sleep(i32 1)
440 // CHECK: call void @llvm.amdgcn.s.sleep(i32 15)
443 __builtin_amdgcn_s_sleep(1);
444 __builtin_amdgcn_s_sleep(15);
447 // CHECK-LABEL: @test_s_incperflevel
448 // CHECK: call void @llvm.amdgcn.s.incperflevel(i32 1)
449 // CHECK: call void @llvm.amdgcn.s.incperflevel(i32 15)
450 void test_s_incperflevel()
452 __builtin_amdgcn_s_incperflevel(1);
453 __builtin_amdgcn_s_incperflevel(15);
456 // CHECK-LABEL: @test_s_decperflevel
457 // CHECK: call void @llvm.amdgcn.s.decperflevel(i32 1)
458 // CHECK: call void @llvm.amdgcn.s.decperflevel(i32 15)
459 void test_s_decperflevel()
461 __builtin_amdgcn_s_decperflevel(1);
462 __builtin_amdgcn_s_decperflevel(15);
465 // CHECK-LABEL: @test_s_setprio
466 // CHECK: call void @llvm.amdgcn.s.setprio(i16 0)
467 // CHECK: call void @llvm.amdgcn.s.setprio(i16 3)
468 void test_s_setprio()
470 __builtin_amdgcn_s_setprio(0);
471 __builtin_amdgcn_s_setprio(3);
474 // CHECK-LABEL: @test_cubeid(
475 // CHECK: call float @llvm.amdgcn.cubeid(float %a, float %b, float %c)
476 void test_cubeid(global float* out, float a, float b, float c) {
477 *out = __builtin_amdgcn_cubeid(a, b, c);
480 // CHECK-LABEL: @test_cubesc(
481 // CHECK: call float @llvm.amdgcn.cubesc(float %a, float %b, float %c)
482 void test_cubesc(global float* out, float a, float b, float c) {
483 *out = __builtin_amdgcn_cubesc(a, b, c);
486 // CHECK-LABEL: @test_cubetc(
487 // CHECK: call float @llvm.amdgcn.cubetc(float %a, float %b, float %c)
488 void test_cubetc(global float* out, float a, float b, float c) {
489 *out = __builtin_amdgcn_cubetc(a, b, c);
492 // CHECK-LABEL: @test_cubema(
493 // CHECK: call float @llvm.amdgcn.cubema(float %a, float %b, float %c)
494 void test_cubema(global float* out, float a, float b, float c) {
495 *out = __builtin_amdgcn_cubema(a, b, c);
498 // CHECK-LABEL: @test_read_exec(
499 // CHECK: call i64 @llvm.read_register.i64(metadata ![[$EXEC:[0-9]+]]) #[[$READ_EXEC_ATTRS:[0-9]+]]
500 void test_read_exec(global ulong* out) {
501 *out = __builtin_amdgcn_read_exec();
504 // CHECK: declare i64 @llvm.read_register.i64(metadata) #[[$NOUNWIND_READONLY:[0-9]+]]
506 // CHECK-LABEL: @test_read_exec_lo(
507 // CHECK: call i32 @llvm.read_register.i32(metadata ![[$EXEC_LO:[0-9]+]]) #[[$READ_EXEC_ATTRS]]
508 void test_read_exec_lo(global uint* out) {
509 *out = __builtin_amdgcn_read_exec_lo();
512 // CHECK-LABEL: @test_read_exec_hi(
513 // CHECK: call i32 @llvm.read_register.i32(metadata ![[$EXEC_HI:[0-9]+]]) #[[$READ_EXEC_ATTRS]]
514 void test_read_exec_hi(global uint* out) {
515 *out = __builtin_amdgcn_read_exec_hi();
518 // CHECK-LABEL: @test_dispatch_ptr
519 // CHECK: call align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
520 void test_dispatch_ptr(__constant unsigned char ** out)
522 *out = __builtin_amdgcn_dispatch_ptr();
525 // CHECK-LABEL: @test_queue_ptr
526 // CHECK: call ptr addrspace(4) @llvm.amdgcn.queue.ptr()
527 void test_queue_ptr(__constant unsigned char ** out)
529 *out = __builtin_amdgcn_queue_ptr();
532 // CHECK-LABEL: @test_kernarg_segment_ptr
533 // CHECK: call ptr addrspace(4) @llvm.amdgcn.kernarg.segment.ptr()
534 void test_kernarg_segment_ptr(__constant unsigned char ** out)
536 *out = __builtin_amdgcn_kernarg_segment_ptr();
539 // CHECK-LABEL: @test_implicitarg_ptr
540 // CHECK: call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
541 void test_implicitarg_ptr(__constant unsigned char ** out)
543 *out = __builtin_amdgcn_implicitarg_ptr();
546 // CHECK-LABEL: @test_get_group_id(
547 // CHECK: tail call i32 @llvm.amdgcn.workgroup.id.x()
548 // CHECK: tail call i32 @llvm.amdgcn.workgroup.id.y()
549 // CHECK: tail call i32 @llvm.amdgcn.workgroup.id.z()
550 void test_get_group_id(int d, global int *out)
553 case 0: *out = __builtin_amdgcn_workgroup_id_x(); break;
554 case 1: *out = __builtin_amdgcn_workgroup_id_y(); break;
555 case 2: *out = __builtin_amdgcn_workgroup_id_z(); break;
560 // CHECK-LABEL: @test_s_getreg(
561 // CHECK: tail call i32 @llvm.amdgcn.s.getreg(i32 0)
562 // CHECK: tail call i32 @llvm.amdgcn.s.getreg(i32 1)
563 // CHECK: tail call i32 @llvm.amdgcn.s.getreg(i32 65535)
564 void test_s_getreg(volatile global uint *out)
566 *out = __builtin_amdgcn_s_getreg(0);
567 *out = __builtin_amdgcn_s_getreg(1);
568 *out = __builtin_amdgcn_s_getreg(65535);
571 // CHECK-LABEL: @test_get_local_id(
572 // CHECK: tail call i32 @llvm.amdgcn.workitem.id.x(), !range [[$WI_RANGE:![0-9]*]], !noundef
573 // CHECK: tail call i32 @llvm.amdgcn.workitem.id.y(), !range [[$WI_RANGE]], !noundef
574 // CHECK: tail call i32 @llvm.amdgcn.workitem.id.z(), !range [[$WI_RANGE]], !noundef
575 void test_get_local_id(int d, global int *out)
578 case 0: *out = __builtin_amdgcn_workitem_id_x(); break;
579 case 1: *out = __builtin_amdgcn_workitem_id_y(); break;
580 case 2: *out = __builtin_amdgcn_workitem_id_z(); break;
585 // CHECK-LABEL: @test_get_workgroup_size(
586 // CHECK: call align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
587 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 4
588 // CHECK: load i16, ptr addrspace(4) %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
589 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 6
590 // CHECK: load i16, ptr addrspace(4) %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
591 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 8
592 // CHECK: load i16, ptr addrspace(4) %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load{{.*}}, !noundef
593 void test_get_workgroup_size(int d, global int *out)
596 case 0: *out = __builtin_amdgcn_workgroup_size_x() + 1; break;
597 case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
598 case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
603 // CHECK-LABEL: @test_get_grid_size(
604 // CHECK: call align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
605 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 12
606 // CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !invariant.load
607 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 16
608 // CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !invariant.load
609 // CHECK: getelementptr i8, ptr addrspace(4) %{{.*}}, i64 20
610 // CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !invariant.load
611 void test_get_grid_size(int d, global int *out)
614 case 0: *out = __builtin_amdgcn_grid_size_x(); break;
615 case 1: *out = __builtin_amdgcn_grid_size_y(); break;
616 case 2: *out = __builtin_amdgcn_grid_size_z(); break;
621 // CHECK-LABEL: @test_fmed3_f32
622 // CHECK: call float @llvm.amdgcn.fmed3.f32(
623 void test_fmed3_f32(global float* out, float a, float b, float c)
625 *out = __builtin_amdgcn_fmed3f(a, b, c);
628 // CHECK-LABEL: @test_s_getpc
629 // CHECK: call i64 @llvm.amdgcn.s.getpc()
630 void test_s_getpc(global ulong* out)
632 *out = __builtin_amdgcn_s_getpc();
635 // CHECK-LABEL: @test_ds_append_lds(
636 // CHECK: call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) %ptr, i1 false)
637 kernel void test_ds_append_lds(global int* out, local int* ptr) {
638 *out = __builtin_amdgcn_ds_append(ptr);
641 // CHECK-LABEL: @test_ds_consume_lds(
642 // CHECK: call i32 @llvm.amdgcn.ds.consume.p3(ptr addrspace(3) %ptr, i1 false)
643 kernel void test_ds_consume_lds(global int* out, local int* ptr) {
644 *out = __builtin_amdgcn_ds_consume(ptr);
647 // CHECK-LABEL: @test_gws_init(
648 // CHECK: call void @llvm.amdgcn.ds.gws.init(i32 %value, i32 %id)
649 kernel void test_gws_init(uint value, uint id) {
650 __builtin_amdgcn_ds_gws_init(value, id);
653 // CHECK-LABEL: @test_gws_barrier(
654 // CHECK: call void @llvm.amdgcn.ds.gws.barrier(i32 %value, i32 %id)
655 kernel void test_gws_barrier(uint value, uint id) {
656 __builtin_amdgcn_ds_gws_barrier(value, id);
659 // CHECK-LABEL: @test_gws_sema_v(
660 // CHECK: call void @llvm.amdgcn.ds.gws.sema.v(i32 %id)
661 kernel void test_gws_sema_v(uint id) {
662 __builtin_amdgcn_ds_gws_sema_v(id);
665 // CHECK-LABEL: @test_gws_sema_br(
666 // CHECK: call void @llvm.amdgcn.ds.gws.sema.br(i32 %value, i32 %id)
667 kernel void test_gws_sema_br(uint value, uint id) {
668 __builtin_amdgcn_ds_gws_sema_br(value, id);
671 // CHECK-LABEL: @test_gws_sema_p(
672 // CHECK: call void @llvm.amdgcn.ds.gws.sema.p(i32 %id)
673 kernel void test_gws_sema_p(uint id) {
674 __builtin_amdgcn_ds_gws_sema_p(id);
677 // CHECK-LABEL: @test_mbcnt_lo(
678 // CHECK: call i32 @llvm.amdgcn.mbcnt.lo(i32 %src0, i32 %src1)
679 kernel void test_mbcnt_lo(global uint* out, uint src0, uint src1) {
680 *out = __builtin_amdgcn_mbcnt_lo(src0, src1);
683 // CHECK-LABEL: @test_mbcnt_hi(
684 // CHECK: call i32 @llvm.amdgcn.mbcnt.hi(i32 %src0, i32 %src1)
685 kernel void test_mbcnt_hi(global uint* out, uint src0, uint src1) {
686 *out = __builtin_amdgcn_mbcnt_hi(src0, src1);
689 // CHECK-LABEL: @test_alignbit(
690 // CHECK: tail call i32 @llvm.fshr.i32(i32 %src0, i32 %src1, i32 %src2)
691 kernel void test_alignbit(global uint* out, uint src0, uint src1, uint src2) {
692 *out = __builtin_amdgcn_alignbit(src0, src1, src2);
695 // CHECK-LABEL: @test_alignbyte(
696 // CHECK: tail call i32 @llvm.amdgcn.alignbyte(i32 %src0, i32 %src1, i32 %src2)
697 kernel void test_alignbyte(global uint* out, uint src0, uint src1, uint src2) {
698 *out = __builtin_amdgcn_alignbyte(src0, src1, src2);
701 // CHECK-LABEL: @test_ubfe(
702 // CHECK: tail call i32 @llvm.amdgcn.ubfe.i32(i32 %src0, i32 %src1, i32 %src2)
703 kernel void test_ubfe(global uint* out, uint src0, uint src1, uint src2) {
704 *out = __builtin_amdgcn_ubfe(src0, src1, src2);
707 // CHECK-LABEL: @test_sbfe(
708 // CHECK: tail call i32 @llvm.amdgcn.sbfe.i32(i32 %src0, i32 %src1, i32 %src2)
709 kernel void test_sbfe(global uint* out, uint src0, uint src1, uint src2) {
710 *out = __builtin_amdgcn_sbfe(src0, src1, src2);
713 // CHECK-LABEL: @test_cvt_pkrtz(
714 // CHECK: tail call <2 x half> @llvm.amdgcn.cvt.pkrtz(float %src0, float %src1)
715 kernel void test_cvt_pkrtz(global half2* out, float src0, float src1) {
716 *out = __builtin_amdgcn_cvt_pkrtz(src0, src1);
719 // CHECK-LABEL: @test_cvt_pknorm_i16(
720 // CHECK: tail call <2 x i16> @llvm.amdgcn.cvt.pknorm.i16(float %src0, float %src1)
721 kernel void test_cvt_pknorm_i16(global short2* out, float src0, float src1) {
722 *out = __builtin_amdgcn_cvt_pknorm_i16(src0, src1);
725 // CHECK-LABEL: @test_cvt_pknorm_u16(
726 // CHECK: tail call <2 x i16> @llvm.amdgcn.cvt.pknorm.u16(float %src0, float %src1)
727 kernel void test_cvt_pknorm_u16(global ushort2* out, float src0, float src1) {
728 *out = __builtin_amdgcn_cvt_pknorm_u16(src0, src1);
731 // CHECK-LABEL: @test_cvt_pk_i16(
732 // CHECK: tail call <2 x i16> @llvm.amdgcn.cvt.pk.i16(i32 %src0, i32 %src1)
733 kernel void test_cvt_pk_i16(global short2* out, int src0, int src1) {
734 *out = __builtin_amdgcn_cvt_pk_i16(src0, src1);
737 // CHECK-LABEL: @test_cvt_pk_u16(
738 // CHECK: tail call <2 x i16> @llvm.amdgcn.cvt.pk.u16(i32 %src0, i32 %src1)
739 kernel void test_cvt_pk_u16(global ushort2* out, uint src0, uint src1) {
740 *out = __builtin_amdgcn_cvt_pk_u16(src0, src1);
743 // CHECK-LABEL: @test_cvt_pk_u8_f32
744 // CHECK: tail call i32 @llvm.amdgcn.cvt.pk.u8.f32(float %src0, i32 %src1, i32 %src2)
745 kernel void test_cvt_pk_u8_f32(global uint* out, float src0, uint src1, uint src2) {
746 *out = __builtin_amdgcn_cvt_pk_u8_f32(src0, src1, src2);
749 // CHECK-LABEL: @test_sad_u8(
750 // CHECK: tail call i32 @llvm.amdgcn.sad.u8(i32 %src0, i32 %src1, i32 %src2)
751 kernel void test_sad_u8(global uint* out, uint src0, uint src1, uint src2) {
752 *out = __builtin_amdgcn_sad_u8(src0, src1, src2);
755 // CHECK-LABEL: test_msad_u8(
756 // CHECK: call i32 @llvm.amdgcn.msad.u8(i32 %src0, i32 %src1, i32 %src2)
757 kernel void test_msad_u8(global uint* out, uint src0, uint src1, uint src2) {
758 *out = __builtin_amdgcn_msad_u8(src0, src1, src2);
761 // CHECK-LABEL: test_sad_hi_u8(
762 // CHECK: call i32 @llvm.amdgcn.sad.hi.u8(i32 %src0, i32 %src1, i32 %src2)
763 kernel void test_sad_hi_u8(global uint* out, uint src0, uint src1, uint src2) {
764 *out = __builtin_amdgcn_sad_hi_u8(src0, src1, src2);
767 // CHECK-LABEL: @test_sad_u16(
768 // CHECK: call i32 @llvm.amdgcn.sad.u16(i32 %src0, i32 %src1, i32 %src2)
769 kernel void test_sad_u16(global uint* out, uint src0, uint src1, uint src2) {
770 *out = __builtin_amdgcn_sad_u16(src0, src1, src2);
773 // CHECK-LABEL: @test_qsad_pk_u16_u8(
774 // CHECK: call i64 @llvm.amdgcn.qsad.pk.u16.u8(i64 %src0, i32 %src1, i64 %src2)
775 kernel void test_qsad_pk_u16_u8(global ulong* out, ulong src0, uint src1, ulong src2) {
776 *out = __builtin_amdgcn_qsad_pk_u16_u8(src0, src1, src2);
779 // CHECK-LABEL: @test_mqsad_pk_u16_u8(
780 // CHECK: call i64 @llvm.amdgcn.mqsad.pk.u16.u8(i64 %src0, i32 %src1, i64 %src2)
781 kernel void test_mqsad_pk_u16_u8(global ulong* out, ulong src0, uint src1, ulong src2) {
782 *out = __builtin_amdgcn_mqsad_pk_u16_u8(src0, src1, src2);
785 // CHECK-LABEL: test_mqsad_u32_u8(
786 // CHECK: call <4 x i32> @llvm.amdgcn.mqsad.u32.u8(i64 %src0, i32 %src1, <4 x i32> %src2)
787 kernel void test_mqsad_u32_u8(global uint4* out, ulong src0, uint src1, uint4 src2) {
788 *out = __builtin_amdgcn_mqsad_u32_u8(src0, src1, src2);
791 // CHECK-LABEL: test_s_setreg(
792 // CHECK: call void @llvm.amdgcn.s.setreg(i32 8193, i32 %val)
793 kernel void test_s_setreg(uint val) {
794 __builtin_amdgcn_s_setreg(8193, val);
797 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
798 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
799 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { mustprogress nocallback nofree nosync nounwind willreturn memory(read) }
800 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
801 // CHECK-DAG: ![[$EXEC]] = !{!"exec"}
802 // CHECK-DAG: ![[$EXEC_LO]] = !{!"exec_lo"}
803 // CHECK-DAG: ![[$EXEC_HI]] = !{!"exec_hi"}