1; RUN: llc -mattr=+promote-alloca -verify-machineinstrs -march=amdgcn < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-PROMOTE %s 2; RUN: llc -mattr=+promote-alloca,-flat-for-global -verify-machineinstrs -mtriple=amdgcn--amdhsa -mcpu=kaveri < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-PROMOTE -check-prefix=HSA %s 3; RUN: llc -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-ALLOCA %s 4; RUN: llc -mattr=-promote-alloca,-flat-for-global -verify-machineinstrs -mtriple=amdgcn-amdhsa -mcpu=kaveri < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-ALLOCA -check-prefix=HSA %s 5; RUN: llc -mattr=+promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-PROMOTE %s 6; RUN: llc -mattr=-promote-alloca -verify-machineinstrs -march=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-ALLOCA %s 7 8 9declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone 10 11 12; Make sure we don't overwrite workitem information with private memory 13 14; GCN-LABEL: {{^}}work_item_info: 15; GCN-NOT: v0 16; GCN: s_load_dword [[IN:s[0-9]+]] 17; GCN-NOT: v0 18 19; GCN-ALLOCA: v_add_{{[iu]}}32_e32 [[RESULT:v[0-9]+]], vcc, v{{[0-9]+}}, v0 20 21; GCN-PROMOTE: v_cmp_eq_u32_e64 vcc, [[IN]], 1 22; GCN-PROMOTE-NEXT: v_addc_u32_e32 [[RESULT:v[0-9]+]], vcc, 0, v0, vcc 23 24; GCN: buffer_store_dword [[RESULT]] 25define amdgpu_kernel void @work_item_info(i32 addrspace(1)* %out, i32 %in) { 26entry: 27 %0 = alloca [2 x i32], addrspace(5) 28 %1 = getelementptr [2 x i32], [2 x i32] addrspace(5)* %0, i32 0, i32 0 29 %2 = getelementptr [2 x i32], [2 x i32] addrspace(5)* %0, i32 0, i32 1 30 store i32 0, i32 addrspace(5)* %1 31 store i32 1, i32 addrspace(5)* %2 32 %3 = getelementptr [2 x i32], [2 x i32] addrspace(5)* %0, i32 0, i32 %in 33 %4 = load i32, i32 addrspace(5)* %3 34 %5 = call i32 @llvm.amdgcn.workitem.id.x() 35 %6 = add i32 %4, %5 36 store i32 %6, i32 addrspace(1)* %out 37 ret void 38} 39