Debian Codegraph @

clang/test/CodeGenOpenCL/builtins-fp-atomics-gfx940.cl

raw
1 // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx940 \
2 // RUN: %s -emit-llvm -o - | FileCheck %s
3
4 // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx940 \
5 // RUN: -S -o - %s | FileCheck -check-prefix=GFX940 %s
6
7 // REQUIRES: amdgpu-registered-target
8
9 typedef half __attribute__((ext_vector_type(2))) half2;
10 typedef short __attribute__((ext_vector_type(2))) short2;
11
12 // CHECK-LABEL: test_flat_add_f32
13 // CHECK: call float @llvm.amdgcn.flat.atomic.fadd.f32.p0.f32(ptr %{{.*}}, float %{{.*}})
14 // GFX940-LABEL: test_flat_add_f32
15 // GFX940: flat_atomic_add_f32
16 half2 test_flat_add_f32(__generic float *addr, float x) {
17 return __builtin_amdgcn_flat_atomic_fadd_f32(addr, x);
18 }
19
20 // CHECK-LABEL: test_flat_add_2f16
21 // CHECK: call <2 x half> @llvm.amdgcn.flat.atomic.fadd.v2f16.p0.v2f16(ptr %{{.*}}, <2 x half> %{{.*}})
22 // GFX940-LABEL: test_flat_add_2f16
23 // GFX940: flat_atomic_pk_add_f16
24 half2 test_flat_add_2f16(__generic half2 *addr, half2 x) {
25 return __builtin_amdgcn_flat_atomic_fadd_v2f16(addr, x);
26 }
27
28 // CHECK-LABEL: test_flat_add_2bf16
29 // CHECK: call <2 x i16> @llvm.amdgcn.flat.atomic.fadd.v2bf16.p0(ptr %{{.*}}, <2 x i16> %{{.*}})
30 // GFX940-LABEL: test_flat_add_2bf16
31 // GFX940: flat_atomic_pk_add_bf16
32 short2 test_flat_add_2bf16(__generic short2 *addr, short2 x) {
33 return __builtin_amdgcn_flat_atomic_fadd_v2bf16(addr, x);
34 }
35
36 // CHECK-LABEL: test_global_add_2bf16
37 // CHECK: call <2 x i16> @llvm.amdgcn.global.atomic.fadd.v2bf16.p1(ptr addrspace(1) %{{.*}}, <2 x i16> %{{.*}})
38 // GFX940-LABEL: test_global_add_2bf16
39 // GFX940: global_atomic_pk_add_bf16
40 short2 test_global_add_2bf16(__global short2 *addr, short2 x) {
41 return __builtin_amdgcn_global_atomic_fadd_v2bf16(addr, x);
42 }
43
44 // CHECK-LABEL: test_local_add_2bf16
45
46 // CHECK: [[BC0:%.+]] = bitcast <2 x i16> {{.+}} to <2 x bfloat>
47 // CHECK: [[RMW:%.+]] = atomicrmw fadd ptr addrspace(3) %{{.+}}, <2 x bfloat> [[BC0]] seq_cst, align 4
48 // CHECK-NEXT: bitcast <2 x bfloat> [[RMW]] to <2 x i16>
49
50 // GFX940-LABEL: test_local_add_2bf16
51 // GFX940: ds_pk_add_rtn_bf16
52 short2 test_local_add_2bf16(__local short2 *addr, short2 x) {
53 return __builtin_amdgcn_ds_atomic_fadd_v2bf16(addr, x);
54 }
55
56 // CHECK-LABEL: test_local_add_2f16
57 // CHECK: = atomicrmw fadd ptr addrspace(3) %{{.+}}, <2 x half> %{{.+}} seq_cst, align 4
58 // GFX940-LABEL: test_local_add_2f16
59 // GFX940: ds_pk_add_rtn_f16
60 half2 test_local_add_2f16(__local half2 *addr, half2 x) {
61 return __builtin_amdgcn_ds_atomic_fadd_v2f16(addr, x);
62 }
63
64 // CHECK-LABEL: test_local_add_2f16_noret
65 // CHECK: = atomicrmw fadd ptr addrspace(3) %{{.+}}, <2 x half> %{{.+}} seq_cst, align 4
66 // GFX940-LABEL: test_local_add_2f16_noret
67 // GFX940: ds_pk_add_f16
68 void test_local_add_2f16_noret(__local half2 *addr, half2 x) {
69 __builtin_amdgcn_ds_atomic_fadd_v2f16(addr, x);
70 }
71
72 // CHECK-LABEL: @test_global_add_f32
73 // CHECK: call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %{{.*}}, float %{{.*}})
74 void test_global_add_f32(float *rtn, global float *addr, float x) {
75 *rtn = __builtin_amdgcn_global_atomic_fadd_f32(addr, x);
76 }