1 ; RUN: llc < %s -march=amdgcn -mcpu=gfx90a -verify-machineinstrs | FileCheck %s -check-prefix=GFX90A
2 ; RUN: not --crash llc < %s -march=amdgcn -mcpu=gfx908 -verify-machineinstrs 2>&1 | FileCheck %s -check-prefix=GFX908
4 declare float @llvm.amdgcn.buffer.atomic.fadd.f32(float, <4 x i32>, i32, i32, i1)
5 declare <2 x half> @llvm.amdgcn.buffer.atomic.fadd.v2f16(<2 x half>, <4 x i32>, i32, i32, i1)
6 declare float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1), float)
7 declare <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1), <2 x half>)
9 ; GFX908: LLVM ERROR: Cannot select: {{.+}}: f32,ch = BUFFER_ATOMIC_FADD
11 ; GFX90A-LABEL: {{^}}buffer_atomic_add_f32:
12 ; GFX90A: buffer_atomic_add_f32 v0, v1, s[0:3], 0 idxen glc
13 define amdgpu_ps float @buffer_atomic_add_f32(<4 x i32> inreg %rsrc, float %data, i32 %vindex) {
15 %ret = call float @llvm.amdgcn.buffer.atomic.fadd.f32(float %data, <4 x i32> %rsrc, i32 %vindex, i32 0, i1 0)
19 ; GFX90A-LABEL: {{^}}buffer_atomic_add_f32_off4_slc:
20 ; GFX90A: buffer_atomic_add_f32 v0, v1, s[0:3], 0 idxen offset:4 glc slc
21 define amdgpu_ps float @buffer_atomic_add_f32_off4_slc(<4 x i32> inreg %rsrc, float %data, i32 %vindex) {
23 %ret = call float @llvm.amdgcn.buffer.atomic.fadd.f32(float %data, <4 x i32> %rsrc, i32 %vindex, i32 4, i1 1)
27 ; GFX90A-LABEL: {{^}}buffer_atomic_pk_add_v2f16:
28 ; GFX90A: buffer_atomic_pk_add_f16 v0, v1, s[0:3], 0 idxen glc
29 define amdgpu_ps <2 x half> @buffer_atomic_pk_add_v2f16(<4 x i32> inreg %rsrc, <2 x half> %data, i32 %vindex) {
31 %ret = call <2 x half> @llvm.amdgcn.buffer.atomic.fadd.v2f16(<2 x half> %data, <4 x i32> %rsrc, i32 %vindex, i32 0, i1 0)
35 ; GFX90A-LABEL: {{^}}buffer_atomic_pk_add_v2f16_off4_slc:
36 ; GFX90A: buffer_atomic_pk_add_f16 v0, v1, s[0:3], 0 idxen offset:4 glc slc
37 define amdgpu_ps <2 x half> @buffer_atomic_pk_add_v2f16_off4_slc(<4 x i32> inreg %rsrc, <2 x half> %data, i32 %vindex) {
39 %ret = call <2 x half> @llvm.amdgcn.buffer.atomic.fadd.v2f16(<2 x half> %data, <4 x i32> %rsrc, i32 %vindex, i32 4, i1 1)
43 ; GFX90A-LABEL: {{^}}global_atomic_add_f32:
44 ; GFX90A: global_atomic_add_f32 v0, v[0:1], v2, off glc
45 define amdgpu_ps float @global_atomic_add_f32(ptr addrspace(1) %ptr, float %data) {
47 %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %ptr, float %data)
51 ; GFX90A-LABEL: {{^}}global_atomic_add_f32_off4:
52 ; GFX90A: global_atomic_add_f32 v0, v[0:1], v2, off offset:4 glc
53 define amdgpu_ps float @global_atomic_add_f32_off4(ptr addrspace(1) %ptr, float %data) {
55 %p = getelementptr float, ptr addrspace(1) %ptr, i64 1
56 %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %p, float %data)
60 ; GFX90A-LABEL: {{^}}global_atomic_add_f32_offneg4:
61 ; GFX90A: global_atomic_add_f32 v0, v[0:1], v2, off offset:-4 glc
62 define amdgpu_ps float @global_atomic_add_f32_offneg4(ptr addrspace(1) %ptr, float %data) {
64 %p = getelementptr float, ptr addrspace(1) %ptr, i64 -1
65 %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %p, float %data)
69 ; GFX90A-LABEL: {{^}}global_atomic_pk_add_v2f16:
70 ; GFX90A: global_atomic_pk_add_f16 v0, v[0:1], v2, off glc
71 define amdgpu_ps <2 x half> @global_atomic_pk_add_v2f16(ptr addrspace(1) %ptr, <2 x half> %data) {
73 %ret = call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %ptr, <2 x half> %data)
77 ; GFX90A-LABEL: {{^}}global_atomic_pk_add_v2f16_off4:
78 ; GFX90A: global_atomic_pk_add_f16 v0, v[0:1], v2, off offset:4 glc
79 define amdgpu_ps <2 x half> @global_atomic_pk_add_v2f16_off4(ptr addrspace(1) %ptr, <2 x half> %data) {
81 %p = getelementptr <2 x half>, ptr addrspace(1) %ptr, i64 1
82 %ret = call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %p, <2 x half> %data)
86 ; GFX90A-LABEL: {{^}}global_atomic_pk_add_v2f16_offneg4:
87 ; GFX90A: global_atomic_pk_add_f16 v0, v[0:1], v2, off offset:-4 glc
88 define amdgpu_ps <2 x half> @global_atomic_pk_add_v2f16_offneg4(ptr addrspace(1) %ptr, <2 x half> %data) {
90 %p = getelementptr <2 x half>, ptr addrspace(1) %ptr, i64 -1
91 %ret = call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %p, <2 x half> %data)