1; RUN: llc -march=amdgcn -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
3
4; FUNC-LABEL: {{^}}test_barrier_local:
5; EG: GROUP_BARRIER
6
7; SI: buffer_store_dword
8; SI: s_waitcnt
9; SI: s_barrier
10
11define void @test_barrier_local(i32 addrspace(1)* %out) {
12entry:
13  %0 = call i32 @llvm.r600.read.tidig.x()
14  %1 = getelementptr i32, i32 addrspace(1)* %out, i32 %0
15  store i32 %0, i32 addrspace(1)* %1
16  call void @llvm.AMDGPU.barrier.local()
17  %2 = call i32 @llvm.r600.read.local.size.x()
18  %3 = sub i32 %2, 1
19  %4 = sub i32 %3, %0
20  %5 = getelementptr i32, i32 addrspace(1)* %out, i32 %4
21  %6 = load i32, i32 addrspace(1)* %5
22  store i32 %6, i32 addrspace(1)* %1
23  ret void
24}
25
26declare void @llvm.AMDGPU.barrier.local()
27
28declare i32 @llvm.r600.read.tidig.x() #0
29declare i32 @llvm.r600.read.local.size.x() #0
30
31attributes #0 = { readnone }
32