71 lines · plain
1; RUN: opt -passes=amdgpu-attributor -mcpu=gfx900 < %s | llc -mcpu=gfx900 | FileCheck -check-prefixes=GCN,RW-FLAT %s2; RUN: opt -passes=amdgpu-attributor -mcpu=gfx900 -mattr=+architected-flat-scratch < %s | llc | FileCheck -check-prefixes=GCN,RO-FLAT %s3; RUN: opt -passes=amdgpu-attributor -mcpu=gfx942 < %s | llc | FileCheck -check-prefixes=GCN,RO-FLAT %s4 5target triple = "amdgcn-amd-amdhsa"6 7; Make sure flat_scratch_init is set8 9; GCN-LABEL: {{^}}stack_object_addrspacecast_in_kernel_no_calls:10; RW-FLAT: s_add_u32 flat_scratch_lo, s4, s711; RW-FLAT: s_addc_u32 flat_scratch_hi, s5, 012; RO-FLAT-NOT: flat_scratch13; GCN: flat_store_dword14; RO-FLAT-NOT: .amdhsa_user_sgpr_private_segment_buffer15; RW-FLAT: .amdhsa_user_sgpr_flat_scratch_init 116; RO-FLAT-NOT: .amdhsa_user_sgpr_flat_scratch_init17; RW-FLAT: .amdhsa_system_sgpr_private_segment_wavefront_offset18; RW-FLAT-NOT: .amdhsa_enable_private_segment19; RO-FLAT-NOT: .amdhsa_system_sgpr_private_segment_wavefront_offset20; RO-FLAT: .amdhsa_enable_private_segment 121; GCN: COMPUTE_PGM_RSRC2:SCRATCH_EN: 122; RW-FLAT: COMPUTE_PGM_RSRC2:USER_SGPR: 623; RO-FLAT: COMPUTE_PGM_RSRC2:USER_SGPR: 024define amdgpu_kernel void @stack_object_addrspacecast_in_kernel_no_calls() {25 %alloca = alloca i32, addrspace(5)26 %cast = addrspacecast ptr addrspace(5) %alloca to ptr27 store volatile i32 0, ptr %cast28 ret void29}30 31; TODO: Could optimize out in this case32; GCN-LABEL: {{^}}stack_object_in_kernel_no_calls:33; RO-FLAT-NOT: flat_scratch34; RW-FLAT: buffer_store_dword35; RO-FLAT: scratch_store_dword36; RW-FLAT: .amdhsa_user_sgpr_private_segment_buffer 137; RO-FLAT-NOT: .amdhsa_user_sgpr_private_segment_buffer38; RW-FLAT: .amdhsa_user_sgpr_flat_scratch_init 039; RO-FLAT-NOT: .amdhsa_user_sgpr_flat_scratch_init40; RW-FLAT: .amdhsa_system_sgpr_private_segment_wavefront_offset 141; RW-FLAT-NOT: .amdhsa_enable_private_segment42; RO-FLAT-NOT: .amdhsa_system_sgpr_private_segment_wavefront_offset43; RO-FLAT: .amdhsa_enable_private_segment 144; RW-FLAT: .amdhsa_reserve_flat_scratch 045; GCN: COMPUTE_PGM_RSRC2:SCRATCH_EN: 146; RW-FLAT: COMPUTE_PGM_RSRC2:USER_SGPR: 447; RO-FLAT: COMPUTE_PGM_RSRC2:USER_SGPR: 048define amdgpu_kernel void @stack_object_in_kernel_no_calls() {49 %alloca = alloca i32, addrspace(5)50 store volatile i32 0, ptr addrspace(5) %alloca51 ret void52}53 54; GCN-LABEL: {{^}}kernel_no_calls_no_stack:55; GCN-NOT: flat_scratch56; RW-FLAT: .amdhsa_user_sgpr_private_segment_buffer 157; RO-FLAT-NOT: .amdhsa_user_sgpr_private_segment_buffer58; RW-FLAT: .amdhsa_user_sgpr_flat_scratch_init 059; RO-FLAT-NOT: .amdhsa_user_sgpr_flat_scratch_init60; RW-FLAT: .amdhsa_system_sgpr_private_segment_wavefront_offset 061; RW-FLAT-NOT: .amdhsa_enable_private_segment62; RO-FLAT-NOT: .amdhsa_system_sgpr_private_segment_wavefront_offset63; RO-FLAT: .amdhsa_enable_private_segment 064; RW-FLAT: .amdhsa_reserve_flat_scratch 065; GCN: COMPUTE_PGM_RSRC2:SCRATCH_EN: 066; RW-FLAT: COMPUTE_PGM_RSRC2:USER_SGPR: 467; RO-FLAT: COMPUTE_PGM_RSRC2:USER_SGPR: 068define amdgpu_kernel void @kernel_no_calls_no_stack() {69 ret void70}71