1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3
4define i32 @atomic_nand_i32_lds(i32 addrspace(3)* %ptr) nounwind {
5; GCN-LABEL: atomic_nand_i32_lds:
6; GCN:       ; %bb.0:
7; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
8; GCN-NEXT:    ds_read_b32 v1, v0
9; GCN-NEXT:    s_mov_b64 s[4:5], 0
10; GCN-NEXT:  BB0_1: ; %atomicrmw.start
11; GCN-NEXT:    ; =>This Inner Loop Header: Depth=1
12; GCN-NEXT:    s_waitcnt lgkmcnt(0)
13; GCN-NEXT:    v_mov_b32_e32 v2, v1
14; GCN-NEXT:    v_not_b32_e32 v1, v2
15; GCN-NEXT:    v_or_b32_e32 v1, -5, v1
16; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
17; GCN-NEXT:    ds_cmpst_rtn_b32 v1, v0, v2, v1
18; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
19; GCN-NEXT:    buffer_wbinvl1_vol
20; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, v1, v2
21; GCN-NEXT:    s_or_b64 s[4:5], vcc, s[4:5]
22; GCN-NEXT:    s_andn2_b64 exec, exec, s[4:5]
23; GCN-NEXT:    s_cbranch_execnz BB0_1
24; GCN-NEXT:  ; %bb.2: ; %atomicrmw.end
25; GCN-NEXT:    s_or_b64 exec, exec, s[4:5]
26; GCN-NEXT:    v_mov_b32_e32 v0, v1
27; GCN-NEXT:    s_setpc_b64 s[30:31]
28  %result = atomicrmw nand i32 addrspace(3)* %ptr, i32 4 seq_cst
29  ret i32 %result
30}
31
32define i32 @atomic_nand_i32_global(i32 addrspace(1)* %ptr) nounwind {
33; GCN-LABEL: atomic_nand_i32_global:
34; GCN:       ; %bb.0:
35; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
36; GCN-NEXT:    global_load_dword v2, v[0:1], off
37; GCN-NEXT:    s_mov_b64 s[4:5], 0
38; GCN-NEXT:  BB1_1: ; %atomicrmw.start
39; GCN-NEXT:    ; =>This Inner Loop Header: Depth=1
40; GCN-NEXT:    s_waitcnt vmcnt(0)
41; GCN-NEXT:    v_mov_b32_e32 v3, v2
42; GCN-NEXT:    v_not_b32_e32 v2, v3
43; GCN-NEXT:    v_or_b32_e32 v2, -5, v2
44; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
45; GCN-NEXT:    global_atomic_cmpswap v2, v[0:1], v[2:3], off glc
46; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
47; GCN-NEXT:    buffer_wbinvl1_vol
48; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, v2, v3
49; GCN-NEXT:    s_or_b64 s[4:5], vcc, s[4:5]
50; GCN-NEXT:    s_andn2_b64 exec, exec, s[4:5]
51; GCN-NEXT:    s_cbranch_execnz BB1_1
52; GCN-NEXT:  ; %bb.2: ; %atomicrmw.end
53; GCN-NEXT:    s_or_b64 exec, exec, s[4:5]
54; GCN-NEXT:    v_mov_b32_e32 v0, v2
55; GCN-NEXT:    s_setpc_b64 s[30:31]
56  %result = atomicrmw nand i32 addrspace(1)* %ptr, i32 4 seq_cst
57  ret i32 %result
58}
59
60define i32 @atomic_nand_i32_flat(i32* %ptr) nounwind {
61; GCN-LABEL: atomic_nand_i32_flat:
62; GCN:       ; %bb.0:
63; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
64; GCN-NEXT:    flat_load_dword v2, v[0:1]
65; GCN-NEXT:    s_mov_b64 s[4:5], 0
66; GCN-NEXT:  BB2_1: ; %atomicrmw.start
67; GCN-NEXT:    ; =>This Inner Loop Header: Depth=1
68; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
69; GCN-NEXT:    v_mov_b32_e32 v3, v2
70; GCN-NEXT:    v_not_b32_e32 v2, v3
71; GCN-NEXT:    v_or_b32_e32 v2, -5, v2
72; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
73; GCN-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
74; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
75; GCN-NEXT:    buffer_wbinvl1_vol
76; GCN-NEXT:    s_waitcnt lgkmcnt(0)
77; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, v2, v3
78; GCN-NEXT:    s_or_b64 s[4:5], vcc, s[4:5]
79; GCN-NEXT:    s_andn2_b64 exec, exec, s[4:5]
80; GCN-NEXT:    s_cbranch_execnz BB2_1
81; GCN-NEXT:  ; %bb.2: ; %atomicrmw.end
82; GCN-NEXT:    s_or_b64 exec, exec, s[4:5]
83; GCN-NEXT:    v_mov_b32_e32 v0, v2
84; GCN-NEXT:    s_setpc_b64 s[30:31]
85  %result = atomicrmw nand i32* %ptr, i32 4 seq_cst
86  ret i32 %result
87}
88