1; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
2; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -mattr=-flat-for-global < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
3; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx900 < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX9 %s
4
5; If flat_store_dword and flat_load_dword use different registers for the data
6; operand, this test is not broken.  It just means it is no longer testing
7; for the original bug.
8
9; GCN: {{^}}test:
10; XGCN: flat_store_dword v[{{[0-9]+:[0-9]+}}], [[DATA:v[0-9]+]]
11; XGCN: s_waitcnt vmcnt(0) lgkmcnt(0)
12; XGCN: flat_load_dword [[DATA]], v[{{[0-9]+:[0-9]+}}]
13define amdgpu_kernel void @test(i32* %out, i32 %in) {
14  store volatile i32 0, i32* %out
15  %val = load volatile i32, i32* %out
16  ret void
17}
18
19; Make sure lgkmcnt isn't used for global_ addrspace(5)* instructions
20; GCN-LABEL: {{^}}test_waitcnt_type_flat_global:
21; GFX9: global_load_dword [[LD:v[0-9]+]]
22; GFX9-NEXT: s_waitcnt vmcnt(0){{$}}
23; GFX9-NEXT: ds_write_b32 [[LD]]
24define amdgpu_kernel void @test_waitcnt_type_flat_global(i32 addrspace(1)* %in) {
25  %val = load volatile i32, i32 addrspace(1)* %in
26  store volatile i32 %val, i32 addrspace(3)* undef
27  ret void
28}
29