[PowerPC] Recommit r314244 with refactoring and off by default
[llvm-core.git] / test / CodeGen / AMDGPU / llvm.amdgcn.s.barrier.ll
blob5a29072a07c339d96fbfd4a607aa20ddd9f497ad
1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=GFX8 -check-prefix=NOAUTO %s
2 ; RUN: llc -march=amdgcn -mattr=+auto-waitcnt-before-barrier -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=GFX8 -check-prefix=AUTO %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=GFX9 -check-prefix=NOAUTO %s
4 ; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=+auto-waitcnt-before-barrier -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=GFX9 -check-prefix=AUTO %s
6 ; GCN-LABEL: {{^}}test_barrier:
7 ; GFX8: buffer_store_dword
8 ; GFX9: global_store_dword
9 ; NOAUTO: s_waitcnt
10 ; AUTO-NOT: s_waitcnt
11 ; GCN: s_barrier
12 define amdgpu_kernel void @test_barrier(i32 addrspace(1)* %out, i32 %size) #0 {
13 entry:
14   %tmp = call i32 @llvm.amdgcn.workitem.id.x()
15   %tmp1 = getelementptr i32, i32 addrspace(1)* %out, i32 %tmp
16   store i32 %tmp, i32 addrspace(1)* %tmp1
17   call void @llvm.amdgcn.s.barrier()
18   %tmp3 = sub i32 %size, 1
19   %tmp4 = sub i32 %tmp3, %tmp
20   %tmp5 = getelementptr i32, i32 addrspace(1)* %out, i32 %tmp4
21   %tmp6 = load i32, i32 addrspace(1)* %tmp5
22   store i32 %tmp6, i32 addrspace(1)* %tmp1
23   ret void
26 declare void @llvm.amdgcn.s.barrier() #1
27 declare i32 @llvm.amdgcn.workitem.id.x() #2
29 attributes #0 = { nounwind }
30 attributes #1 = { convergent nounwind }
31 attributes #2 = { nounwind readnone }