1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX940 %s
3 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -atomic-expand < %s | FileCheck --check-prefix=OPT %s
5 define i32 @global_agent_monotonic_idempotent_or(ptr addrspace(1) %in) {
6 ; GFX940-LABEL: global_agent_monotonic_idempotent_or:
7 ; GFX940: ; %bb.0: ; %entry
8 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
9 ; GFX940-NEXT: global_load_dword v0, v[0:1], off sc1
10 ; GFX940-NEXT: s_waitcnt vmcnt(0)
11 ; GFX940-NEXT: s_setpc_b64 s[30:31]
12 ; OPT-LABEL: @global_agent_monotonic_idempotent_or(
14 ; OPT-NEXT: [[VAL:%.*]] = load atomic i32, ptr addrspace(1) [[IN:%.*]] syncscope("agent-one-as") monotonic, align 4
15 ; OPT-NEXT: ret i32 [[VAL]]
18 %val = atomicrmw or ptr addrspace(1) %in, i32 0 syncscope("agent-one-as") monotonic, align 4
22 define i32 @global_agent_acquire_idempotent_or(ptr addrspace(1) %in) {
23 ; GFX940-LABEL: global_agent_acquire_idempotent_or:
24 ; GFX940: ; %bb.0: ; %entry
25 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
26 ; GFX940-NEXT: global_load_dword v0, v[0:1], off sc1
27 ; GFX940-NEXT: s_waitcnt vmcnt(0)
28 ; GFX940-NEXT: buffer_inv sc1
29 ; GFX940-NEXT: s_setpc_b64 s[30:31]
30 ; OPT-LABEL: @global_agent_acquire_idempotent_or(
32 ; OPT-NEXT: [[VAL:%.*]] = load atomic i32, ptr addrspace(1) [[IN:%.*]] syncscope("agent-one-as") acquire, align 4
33 ; OPT-NEXT: ret i32 [[VAL]]
36 %val = atomicrmw or ptr addrspace(1) %in, i32 0 syncscope("agent-one-as") acquire, align 4
40 define i32 @global_agent_release_idempotent_or(ptr addrspace(1) %in) {
41 ; GFX940-LABEL: global_agent_release_idempotent_or:
42 ; GFX940: ; %bb.0: ; %entry
43 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
44 ; GFX940-NEXT: v_mov_b32_e32 v2, 0
45 ; GFX940-NEXT: buffer_wbl2 sc1
46 ; GFX940-NEXT: s_waitcnt vmcnt(0)
47 ; GFX940-NEXT: global_atomic_or v0, v[0:1], v2, off sc0
48 ; GFX940-NEXT: s_waitcnt vmcnt(0)
49 ; GFX940-NEXT: s_setpc_b64 s[30:31]
50 ; OPT-LABEL: @global_agent_release_idempotent_or(
52 ; OPT-NEXT: [[VAL:%.*]] = atomicrmw or ptr addrspace(1) [[IN:%.*]], i32 0 syncscope("agent-one-as") release, align 4
53 ; OPT-NEXT: ret i32 [[VAL]]
56 %val = atomicrmw or ptr addrspace(1) %in, i32 0 syncscope("agent-one-as") release, align 4
60 define i32 @global_agent_acquire_release_idempotent_or(ptr addrspace(1) %in) {
61 ; GFX940-LABEL: global_agent_acquire_release_idempotent_or:
62 ; GFX940: ; %bb.0: ; %entry
63 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
64 ; GFX940-NEXT: v_mov_b32_e32 v2, 0
65 ; GFX940-NEXT: buffer_wbl2 sc1
66 ; GFX940-NEXT: s_waitcnt vmcnt(0)
67 ; GFX940-NEXT: global_atomic_or v0, v[0:1], v2, off sc0
68 ; GFX940-NEXT: s_waitcnt vmcnt(0)
69 ; GFX940-NEXT: buffer_inv sc1
70 ; GFX940-NEXT: s_setpc_b64 s[30:31]
71 ; OPT-LABEL: @global_agent_acquire_release_idempotent_or(
73 ; OPT-NEXT: [[VAL:%.*]] = atomicrmw or ptr addrspace(1) [[IN:%.*]], i32 0 syncscope("agent-one-as") acq_rel, align 4
74 ; OPT-NEXT: ret i32 [[VAL]]
77 %val = atomicrmw or ptr addrspace(1) %in, i32 0 syncscope("agent-one-as") acq_rel, align 4
81 define i32 @global_agent_seq_cst_idempotent_or(ptr addrspace(1) %in) {
82 ; GFX940-LABEL: global_agent_seq_cst_idempotent_or:
83 ; GFX940: ; %bb.0: ; %entry
84 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
85 ; GFX940-NEXT: v_mov_b32_e32 v2, 0
86 ; GFX940-NEXT: buffer_wbl2 sc1
87 ; GFX940-NEXT: s_waitcnt vmcnt(0)
88 ; GFX940-NEXT: global_atomic_or v0, v[0:1], v2, off sc0
89 ; GFX940-NEXT: s_waitcnt vmcnt(0)
90 ; GFX940-NEXT: buffer_inv sc1
91 ; GFX940-NEXT: s_setpc_b64 s[30:31]
92 ; OPT-LABEL: @global_agent_seq_cst_idempotent_or(
94 ; OPT-NEXT: [[VAL:%.*]] = atomicrmw or ptr addrspace(1) [[IN:%.*]], i32 0 syncscope("agent-one-as") seq_cst, align 4
95 ; OPT-NEXT: ret i32 [[VAL]]
98 %val = atomicrmw or ptr addrspace(1) %in, i32 0 syncscope("agent-one-as") seq_cst, align 4
102 define i32 @global_agent_monotonic_idempotent_add(ptr addrspace(1) %in) {
103 ; GFX940-LABEL: global_agent_monotonic_idempotent_add:
104 ; GFX940: ; %bb.0: ; %entry
105 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
106 ; GFX940-NEXT: global_load_dword v0, v[0:1], off sc0
107 ; GFX940-NEXT: s_waitcnt vmcnt(0)
108 ; GFX940-NEXT: s_setpc_b64 s[30:31]
109 ; OPT-LABEL: @global_agent_monotonic_idempotent_add(
111 ; OPT-NEXT: [[VAL:%.*]] = load atomic i32, ptr addrspace(1) [[IN:%.*]] syncscope("workgroup") monotonic, align 4
112 ; OPT-NEXT: ret i32 [[VAL]]
115 %val = atomicrmw add ptr addrspace(1) %in, i32 0 syncscope("workgroup") monotonic, align 4
119 define i32 @global_agent_monotonic_idempotent_sub(ptr addrspace(1) %in) {
120 ; GFX940-LABEL: global_agent_monotonic_idempotent_sub:
121 ; GFX940: ; %bb.0: ; %entry
122 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
123 ; GFX940-NEXT: global_load_dword v0, v[0:1], off
124 ; GFX940-NEXT: s_waitcnt vmcnt(0)
125 ; GFX940-NEXT: s_setpc_b64 s[30:31]
126 ; OPT-LABEL: @global_agent_monotonic_idempotent_sub(
128 ; OPT-NEXT: [[VAL:%.*]] = load atomic i32, ptr addrspace(1) [[IN:%.*]] syncscope("wavefront") monotonic, align 4
129 ; OPT-NEXT: ret i32 [[VAL]]
132 %val = atomicrmw sub ptr addrspace(1) %in, i32 0 syncscope("wavefront") monotonic, align 4
136 define i32 @global_system_monotonic_idempotent_xor(ptr addrspace(1) %in) {
137 ; GFX940-LABEL: global_system_monotonic_idempotent_xor:
138 ; GFX940: ; %bb.0: ; %entry
139 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
140 ; GFX940-NEXT: global_load_dword v0, v[0:1], off sc0 sc1
141 ; GFX940-NEXT: s_waitcnt vmcnt(0)
142 ; GFX940-NEXT: s_setpc_b64 s[30:31]
143 ; OPT-LABEL: @global_system_monotonic_idempotent_xor(
145 ; OPT-NEXT: [[VAL:%.*]] = load atomic i32, ptr addrspace(1) [[IN:%.*]] monotonic, align 4
146 ; OPT-NEXT: ret i32 [[VAL]]
149 %val = atomicrmw xor ptr addrspace(1) %in, i32 0 monotonic, align 4
153 define i32 @global_agent_monotonic_idempotent_and(ptr addrspace(1) %in) {
154 ; GFX940-LABEL: global_agent_monotonic_idempotent_and:
155 ; GFX940: ; %bb.0: ; %entry
156 ; GFX940-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
157 ; GFX940-NEXT: global_load_dword v0, v[0:1], off
158 ; GFX940-NEXT: s_waitcnt vmcnt(0)
159 ; GFX940-NEXT: s_setpc_b64 s[30:31]
160 ; OPT-LABEL: @global_agent_monotonic_idempotent_and(
162 ; OPT-NEXT: [[VAL:%.*]] = load atomic i32, ptr addrspace(1) [[IN:%.*]] syncscope("singlethread") monotonic, align 4
163 ; OPT-NEXT: ret i32 [[VAL]]
166 %val = atomicrmw and ptr addrspace(1) %in, i32 -1 syncscope("singlethread") monotonic, align 4