1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,CI %s
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX9 %s
3
4; GCN-LABEL: {{^}}atomic_store_monotonic_i32:
5; GCN: s_waitcnt
6; GFX9-NOT: s_mov_b32 m0
7; CI-NEXT: s_mov_b32 m0
8; GCN-NEXT: ds_write_b32 v0, v1{{$}}
9; GCN-NEXT: s_waitcnt lgkmcnt(0)
10; GCN-NEXT: s_setpc_b64
11define void @atomic_store_monotonic_i32(i32 addrspace(3)* %ptr, i32 %val) {
12  store atomic i32 %val, i32 addrspace(3)* %ptr monotonic, align 4
13  ret void
14}
15
16; GCN-LABEL: {{^}}atomic_store_monotonic_offset_i32:
17; GCN: s_waitcnt
18; GFX9-NOT: s_mov_b32 m0
19; CI-NEXT: s_mov_b32 m0
20; GCN-NEXT: ds_write_b32 v0, v1 offset:64{{$}}
21; GCN-NEXT: s_waitcnt lgkmcnt(0)
22; GCN-NEXT: s_setpc_b64
23define void @atomic_store_monotonic_offset_i32(i32 addrspace(3)* %ptr, i32 %val) {
24  %gep = getelementptr inbounds i32, i32 addrspace(3)* %ptr, i32 16
25  store atomic i32 %val, i32 addrspace(3)* %gep monotonic, align 4
26  ret void
27}
28
29; GCN-LABEL: {{^}}atomic_store_monotonic_i64:
30; GCN: s_waitcnt
31; GFX9-NOT: s_mov_b32 m0
32; CI-NEXT: s_mov_b32 m0
33; GCN-NEXT: ds_write_b64 v0, v[1:2]{{$}}
34; GCN-NEXT: s_waitcnt lgkmcnt(0)
35; GCN-NEXT: s_setpc_b64
36define void @atomic_store_monotonic_i64(i64 addrspace(3)* %ptr, i64 %val) {
37  store atomic i64 %val, i64 addrspace(3)* %ptr monotonic, align 8
38  ret void
39}
40
41; GCN-LABEL: {{^}}atomic_store_monotonic_offset_i64:
42; GCN: s_waitcnt
43; GFX9-NOT: s_mov_b32 m0
44; CI-NEXT: s_mov_b32 m0
45; GCN-NEXT: ds_write_b64 v0, v[1:2] offset:128{{$}}
46; GCN-NEXT: s_waitcnt lgkmcnt(0)
47; GCN-NEXT: s_setpc_b64
48define void @atomic_store_monotonic_offset_i64(i64 addrspace(3)* %ptr, i64 %val) {
49  %gep = getelementptr inbounds i64, i64 addrspace(3)* %ptr, i64 16
50  store atomic i64 %val, i64 addrspace(3)* %gep monotonic, align 8
51  ret void
52}
53
54