1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI %s
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX9 %s
5 ; GCN-LABEL: {{^}}is_private_vgpr:
6 ; GCN-DAG: {{flat|global|buffer}}_load_dwordx2 v{{\[[0-9]+}}:[[PTR_HI:[0-9]+]]]
7 ; CI-DAG: s_load_dword [[APERTURE:s[0-9]+]], s[4:5], 0x11
8 ; CI: v_cmp_eq_u32_e32 vcc, [[APERTURE]], v[[PTR_HI]]
10 ; GFX9: s_mov_b64 s[{{[0-9]+}}:[[HI:[0-9]+]]], src_private_base
11 ; GFX9: v_cmp_eq_u32_e32 vcc, s[[HI]], v[[PTR_HI]]
13 ; GCN: v_cndmask_b32_e64 v{{[0-9]+}}, 0, 1, vcc
14 define amdgpu_kernel void @is_private_vgpr(ptr addrspace(1) %ptr.ptr) {
15 %id = call i32 @llvm.amdgcn.workitem.id.x()
16 %gep = getelementptr inbounds ptr, ptr addrspace(1) %ptr.ptr, i32 %id
17 %ptr = load volatile ptr, ptr addrspace(1) %gep
18 %val = call i1 @llvm.amdgcn.is.private(ptr %ptr)
19 %ext = zext i1 %val to i32
20 store i32 %ext, ptr addrspace(1) undef
24 ; FIXME: setcc (zero_extend (setcc)), 1) not folded out, resulting in
25 ; select and vcc branch.
27 ; GCN-LABEL: {{^}}is_private_sgpr:
28 ; CI-DAG: s_load_dword [[APERTURE:s[0-9]+]], s[4:5], 0x11{{$}}
30 ; CI-DAG: s_load_dword [[PTR_HI:s[0-9]+]], s[6:7], 0x1{{$}}
31 ; GFX9-DAG: s_load_dword [[PTR_HI:s[0-9]+]], s[4:5], 0x4{{$}}
33 ; CI: s_cmp_eq_u32 [[PTR_HI]], [[APERTURE]]
35 ; GFX9: s_mov_b64 s[{{[0-9]+}}:[[HI:[0-9]+]]], src_private_base
36 ; GFX9: s_cmp_eq_u32 [[PTR_HI]], s[[HI]]
38 ; GCN: s_cbranch_vccnz
39 define amdgpu_kernel void @is_private_sgpr(ptr %ptr) {
40 %val = call i1 @llvm.amdgcn.is.private(ptr %ptr)
41 br i1 %val, label %bb0, label %bb1
44 store volatile i32 0, ptr addrspace(1) undef
51 declare i32 @llvm.amdgcn.workitem.id.x() #0
52 declare i1 @llvm.amdgcn.is.private(ptr nocapture) #0
54 attributes #0 = { nounwind readnone speculatable }