1 ; RUN: llc -mattr=+promote-alloca -verify-machineinstrs -mtriple=amdgcn < %s | FileCheck --check-prefixes=GCN,GCN-PROMOTE %s
2 ; RUN: llc -mattr=+promote-alloca,-flat-for-global -verify-machineinstrs -mtriple=amdgcn--amdhsa -mcpu=kaveri < %s | FileCheck --check-prefixes=GCN,GCN-PROMOTE %s
3 ; RUN: llc -mattr=-promote-alloca -verify-machineinstrs -mtriple=amdgcn < %s | FileCheck --check-prefixes=GCN,GCN-ALLOCA %s
4 ; RUN: llc -mattr=-promote-alloca,-flat-for-global -verify-machineinstrs -mtriple=amdgcn-amdhsa -mcpu=kaveri < %s | FileCheck --check-prefixes=GCN,GCN-ALLOCA %s
5 ; RUN: llc -mattr=+promote-alloca -verify-machineinstrs -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck --check-prefixes=GCN,GCN-PROMOTE %s
6 ; RUN: llc -mattr=-promote-alloca -verify-machineinstrs -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck --check-prefixes=GCN,GCN-ALLOCA %s
9 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
12 ; Make sure we don't overwrite workitem information with private memory
14 ; GCN-LABEL: {{^}}work_item_info:
16 ; GCN: s_load_dword [[IN:s[0-9]+]]
19 ; GCN-ALLOCA: v_add_{{[iu]}}32_e32 [[RESULT:v[0-9]+]], vcc, v{{[0-9]+}}, v0
21 ; GCN-PROMOTE: s_cmp_eq_u32 [[IN]], 1
22 ; GCN-PROMOTE-NEXT: s_cselect_b64 vcc, -1, 0
23 ; GCN-PROMOTE-NEXT: v_addc_u32_e32 [[RESULT:v[0-9]+]], vcc, 0, v0, vcc
25 ; GCN: buffer_store_dword [[RESULT]]
26 define amdgpu_kernel void @work_item_info(ptr addrspace(1) %out, i32 %in) {
28 %0 = alloca [2 x i32], addrspace(5)
29 %1 = getelementptr [2 x i32], ptr addrspace(5) %0, i32 0, i32 1
30 store i32 0, ptr addrspace(5) %0
31 store i32 1, ptr addrspace(5) %1
32 %2 = getelementptr [2 x i32], ptr addrspace(5) %0, i32 0, i32 %in
33 %3 = load i32, ptr addrspace(5) %2
34 %4 = call i32 @llvm.amdgcn.workitem.id.x()
36 store i32 %5, ptr addrspace(1) %out