1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX10
3 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1031 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX10
4 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX11
6 define i32 @global_atomic_csub(ptr addrspace(1) %ptr, i32 %data) {
7 ; GFX10-LABEL: global_atomic_csub:
9 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
11 ; GFX10-NEXT: s_waitcnt vmcnt(0)
12 ; GFX10-NEXT: s_setpc_b64 s[30:31]
14 ; GFX11-LABEL: global_atomic_csub:
16 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
17 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
18 ; GFX11-NEXT: s_waitcnt vmcnt(0)
19 ; GFX11-NEXT: s_setpc_b64 s[30:31]
20 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %ptr, i32 %data)
24 define i32 @global_atomic_csub_offset(ptr addrspace(1) %ptr, i32 %data) {
25 ; GFX10-LABEL: global_atomic_csub_offset:
27 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
28 ; GFX10-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
29 ; GFX10-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
30 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
31 ; GFX10-NEXT: s_waitcnt vmcnt(0)
32 ; GFX10-NEXT: s_setpc_b64 s[30:31]
34 ; GFX11-LABEL: global_atomic_csub_offset:
36 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
37 ; GFX11-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
38 ; GFX11-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
39 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
40 ; GFX11-NEXT: s_waitcnt vmcnt(0)
41 ; GFX11-NEXT: s_setpc_b64 s[30:31]
42 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
43 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
47 define void @global_atomic_csub_nortn(ptr addrspace(1) %ptr, i32 %data) {
48 ; GFX10-LABEL: global_atomic_csub_nortn:
50 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
51 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
52 ; GFX10-NEXT: s_waitcnt vmcnt(0)
53 ; GFX10-NEXT: s_setpc_b64 s[30:31]
55 ; GFX11-LABEL: global_atomic_csub_nortn:
57 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
58 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
59 ; GFX11-NEXT: s_waitcnt vmcnt(0)
60 ; GFX11-NEXT: s_setpc_b64 s[30:31]
61 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %ptr, i32 %data)
65 define void @global_atomic_csub_offset_nortn(ptr addrspace(1) %ptr, i32 %data) {
66 ; GFX10-LABEL: global_atomic_csub_offset_nortn:
68 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
69 ; GFX10-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
70 ; GFX10-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
71 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
72 ; GFX10-NEXT: s_waitcnt vmcnt(0)
73 ; GFX10-NEXT: s_setpc_b64 s[30:31]
75 ; GFX11-LABEL: global_atomic_csub_offset_nortn:
77 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
78 ; GFX11-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
79 ; GFX11-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
80 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
81 ; GFX11-NEXT: s_waitcnt vmcnt(0)
82 ; GFX11-NEXT: s_setpc_b64 s[30:31]
83 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
84 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
88 define amdgpu_kernel void @global_atomic_csub_sgpr_base_offset(ptr addrspace(1) %ptr, i32 %data) {
89 ; GFX10-LABEL: global_atomic_csub_sgpr_base_offset:
91 ; GFX10-NEXT: s_clause 0x1
92 ; GFX10-NEXT: s_load_dword s2, s[4:5], 0x8
93 ; GFX10-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
94 ; GFX10-NEXT: v_mov_b32_e32 v1, 0x1000
95 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
96 ; GFX10-NEXT: v_mov_b32_e32 v0, s2
97 ; GFX10-NEXT: global_atomic_csub v0, v1, v0, s[0:1] glc
98 ; GFX10-NEXT: s_waitcnt vmcnt(0)
99 ; GFX10-NEXT: global_store_dword v[0:1], v0, off
100 ; GFX10-NEXT: s_endpgm
102 ; GFX11-LABEL: global_atomic_csub_sgpr_base_offset:
104 ; GFX11-NEXT: s_clause 0x1
105 ; GFX11-NEXT: s_load_b32 s2, s[0:1], 0x8
106 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
107 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
108 ; GFX11-NEXT: v_dual_mov_b32 v1, 0x1000 :: v_dual_mov_b32 v0, s2
109 ; GFX11-NEXT: global_atomic_csub_u32 v0, v1, v0, s[0:1] glc
110 ; GFX11-NEXT: s_waitcnt vmcnt(0)
111 ; GFX11-NEXT: global_store_b32 v[0:1], v0, off
112 ; GFX11-NEXT: s_nop 0
113 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
114 ; GFX11-NEXT: s_endpgm
115 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
116 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
117 store i32 %ret, ptr addrspace(1) undef
121 define amdgpu_kernel void @global_atomic_csub_sgpr_base_offset_nortn(ptr addrspace(1) %ptr, i32 %data) {
122 ; GFX10-LABEL: global_atomic_csub_sgpr_base_offset_nortn:
124 ; GFX10-NEXT: s_clause 0x1
125 ; GFX10-NEXT: s_load_dword s2, s[4:5], 0x8
126 ; GFX10-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
127 ; GFX10-NEXT: v_mov_b32_e32 v1, 0x1000
128 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
129 ; GFX10-NEXT: v_mov_b32_e32 v0, s2
130 ; GFX10-NEXT: global_atomic_csub v0, v1, v0, s[0:1] glc
131 ; GFX10-NEXT: s_endpgm
133 ; GFX11-LABEL: global_atomic_csub_sgpr_base_offset_nortn:
135 ; GFX11-NEXT: s_clause 0x1
136 ; GFX11-NEXT: s_load_b32 s2, s[0:1], 0x8
137 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
138 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
139 ; GFX11-NEXT: v_dual_mov_b32 v1, 0x1000 :: v_dual_mov_b32 v0, s2
140 ; GFX11-NEXT: global_atomic_csub_u32 v0, v1, v0, s[0:1] glc
141 ; GFX11-NEXT: s_endpgm
142 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
143 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
147 declare i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) nocapture, i32) #1
149 attributes #0 = { nounwind willreturn }
150 attributes #1 = { argmemonly nounwind }