248 lines · plain
1; RUN: llc -mtriple=amdgcn--amdpal -mattr=-xnack < %s | FileCheck -check-prefixes=GCN,SDAG,GFX8 -enable-var-scope %s2; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx900 -mattr=-xnack < %s | FileCheck -check-prefixes=GCN,SDAG,GFX9 -enable-var-scope %s3; RUN: llc -global-isel -mtriple=amdgcn--amdpal -mattr=-xnack -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GISEL,GFX9 -enable-var-scope %s4 5declare amdgpu_gfx float @extern_func(float) #06declare amdgpu_gfx float @extern_func_many_args(<64 x float>) #07 8@funcptr = external hidden unnamed_addr addrspace(4) constant ptr, align 49 10define amdgpu_gfx float @no_stack(float %arg0) #0 {11 %add = fadd float %arg0, 1.012 ret float %add13}14 15define amdgpu_gfx float @simple_stack(float %arg0) #0 {16 %stack = alloca float, i32 4, align 4, addrspace(5)17 store volatile float 2.0, ptr addrspace(5) %stack18 %val = load volatile float, ptr addrspace(5) %stack19 %add = fadd float %arg0, %val20 ret float %add21}22 23define amdgpu_gfx float @multiple_stack(float %arg0) #0 {24 %stack = alloca float, i32 4, align 4, addrspace(5)25 store volatile float 2.0, ptr addrspace(5) %stack26 %val = load volatile float, ptr addrspace(5) %stack27 %add = fadd float %arg0, %val28 %stack2 = alloca float, i32 4, align 4, addrspace(5)29 store volatile float 2.0, ptr addrspace(5) %stack230 %val2 = load volatile float, ptr addrspace(5) %stack231 %add2 = fadd float %add, %val232 ret float %add233}34 35define amdgpu_gfx float @dynamic_stack(float %arg0) #0 {36bb0:37 %cmp = fcmp ogt float %arg0, 0.038 br i1 %cmp, label %bb1, label %bb239 40bb1:41 %stack = alloca float, i32 4, align 4, addrspace(5)42 store volatile float 2.0, ptr addrspace(5) %stack43 %val = load volatile float, ptr addrspace(5) %stack44 %add = fadd float %arg0, %val45 br label %bb246 47bb2:48 %res = phi float [ 0.0, %bb0 ], [ %add, %bb1 ]49 ret float %res50}51 52define amdgpu_gfx float @dynamic_stack_loop(float %arg0) #0 {53bb0:54 br label %bb155 56bb1:57 %ctr = phi i32 [ 0, %bb0 ], [ %newctr, %bb1 ]58 %stack = alloca float, i32 4, align 4, addrspace(5)59 store volatile float 2.0, ptr addrspace(5) %stack60 %val = load volatile float, ptr addrspace(5) %stack61 %add = fadd float %arg0, %val62 %cmp = icmp sgt i32 %ctr, 063 %newctr = sub i32 %ctr, 164 br i1 %cmp, label %bb1, label %bb265 66bb2:67 ret float %add68}69 70define amdgpu_gfx float @no_stack_call(float %arg0) #0 {71 %res = call amdgpu_gfx float @simple_stack(float %arg0)72 ret float %res73}74 75define amdgpu_gfx float @simple_stack_call(float %arg0) #0 {76 %stack = alloca float, i32 4, align 4, addrspace(5)77 store volatile float 2.0, ptr addrspace(5) %stack78 %val = load volatile float, ptr addrspace(5) %stack79 %res = call amdgpu_gfx float @simple_stack(float %arg0)80 %add = fadd float %res, %val81 ret float %add82}83 84define amdgpu_gfx float @no_stack_extern_call(float %arg0) #0 {85 %res = call amdgpu_gfx float @extern_func(float %arg0)86 ret float %res87}88 89define amdgpu_gfx float @simple_stack_extern_call(float %arg0) #0 {90 %stack = alloca float, i32 4, align 4, addrspace(5)91 store volatile float 2.0, ptr addrspace(5) %stack92 %val = load volatile float, ptr addrspace(5) %stack93 %res = call amdgpu_gfx float @extern_func(float %arg0)94 %add = fadd float %res, %val95 ret float %add96}97 98define amdgpu_gfx float @no_stack_extern_call_many_args(<64 x float> %arg0) #0 {99 %res = call amdgpu_gfx float @extern_func_many_args(<64 x float> %arg0)100 ret float %res101}102 103define amdgpu_gfx float @no_stack_indirect_call(float %arg0) #0 {104 %fptr = load ptr, ptr addrspace(4) @funcptr105 call amdgpu_gfx void %fptr()106 ret float %arg0107}108 109define amdgpu_gfx float @simple_stack_indirect_call(float %arg0) #0 {110 %stack = alloca float, i32 4, align 4, addrspace(5)111 store volatile float 2.0, ptr addrspace(5) %stack112 %val = load volatile float, ptr addrspace(5) %stack113 %fptr = load ptr, ptr addrspace(4) @funcptr114 call amdgpu_gfx void %fptr()115 %add = fadd float %arg0, %val116 ret float %add117}118 119define amdgpu_gfx float @simple_stack_recurse(float %arg0) #0 {120 %stack = alloca float, i32 4, align 4, addrspace(5)121 store volatile float 2.0, ptr addrspace(5) %stack122 %val = load volatile float, ptr addrspace(5) %stack123 %res = call amdgpu_gfx float @simple_stack_recurse(float %arg0)124 %add = fadd float %res, %val125 ret float %add126}127 128@lds = internal addrspace(3) global [64 x float] poison129 130define amdgpu_gfx float @simple_lds(float %arg0) #0 {131 %val = load float, ptr addrspace(3) @lds132 ret float %val133}134 135define amdgpu_gfx float @simple_lds_recurse(float %arg0) #0 {136 %val = load float, ptr addrspace(3) @lds137 %res = call amdgpu_gfx float @simple_lds_recurse(float %val)138 ret float %res139}140 141attributes #0 = { nounwind }142 143; GCN: amdpal.pipelines:144; GCN-NEXT: - .registers:145; SDAG-NEXT: '0x2e12 (COMPUTE_PGM_RSRC1)': 0xaf01ca{{$}}146; GISEL-NEXT: '0x2e12 (COMPUTE_PGM_RSRC1)': 0xaf01ca{{$}}147; GCN-NEXT: '0x2e13 (COMPUTE_PGM_RSRC2)': 0x8001{{$}}148; GCN-NEXT: .shader_functions:149; GCN-NEXT: dynamic_stack:150; GCN-NEXT: .backend_stack_size: 0x10{{$}}151; GCN-NEXT: .lds_size: 0{{$}}152; GCN-NEXT: .sgpr_count: 0x28{{$}}153; GCN-NEXT: .stack_frame_size_in_bytes: 0x10{{$}}154; SDAG-NEXT: .vgpr_count: 0x2{{$}}155; GISEL-NEXT: .vgpr_count: 0x3{{$}}156; GCN-NEXT: dynamic_stack_loop:157; GCN-NEXT: .backend_stack_size: 0x10{{$}}158; GCN-NEXT: .lds_size: 0{{$}}159; SDAG-NEXT: .sgpr_count: 0x25{{$}}160; GISEL-NEXT: .sgpr_count: 0x26{{$}}161; GCN-NEXT: .stack_frame_size_in_bytes: 0x10{{$}}162; SDAG-NEXT: .vgpr_count: 0x3{{$}}163; GISEL-NEXT: .vgpr_count: 0x4{{$}}164; GCN-NEXT: multiple_stack:165; GCN-NEXT: .backend_stack_size: 0x24{{$}}166; GCN-NEXT: .lds_size: 0{{$}}167; GCN-NEXT: .sgpr_count: 0x21{{$}}168; GCN-NEXT: .stack_frame_size_in_bytes: 0x24{{$}}169; GCN-NEXT: .vgpr_count: 0x3{{$}}170; GCN-NEXT: no_stack:171; GCN-NEXT: .backend_stack_size: 0{{$}}172; GCN-NEXT: .lds_size: 0{{$}}173; GCN-NEXT: .sgpr_count: 0x20{{$}}174; GCN-NEXT: .stack_frame_size_in_bytes: 0{{$}}175; GCN-NEXT: .vgpr_count: 0x1{{$}}176; GCN-NEXT: no_stack_call:177; GCN-NEXT: .backend_stack_size: 0x10{{$}}178; GCN-NEXT: .lds_size: 0{{$}}179; GCN-NEXT: .sgpr_count: 0x25{{$}}180; GCN-NEXT: .stack_frame_size_in_bytes: 0x10{{$}}181; GCN-NEXT: .vgpr_count: 0x3{{$}}182; GCN-NEXT: no_stack_extern_call:183; GCN-NEXT: .backend_stack_size: 0x10{{$}}184; GCN-NEXT: .lds_size: 0{{$}}185; GFX8-NEXT: .sgpr_count: 0x28{{$}}186; GFX9-NEXT: .sgpr_count: 0x2c{{$}}187; GCN-NEXT: .stack_frame_size_in_bytes: 0x10{{$}}188; GCN-NEXT: .vgpr_count: 0x2b{{$}}189; GCN-NEXT: no_stack_extern_call_many_args:190; GCN-NEXT: .backend_stack_size: 0x90{{$}}191; GCN-NEXT: .lds_size: 0{{$}}192; GFX8-NEXT: .sgpr_count: 0x28{{$}}193; GFX9-NEXT: .sgpr_count: 0x2c{{$}}194; GCN-NEXT: .stack_frame_size_in_bytes: 0x90{{$}}195; GCN-NEXT: .vgpr_count: 0x2b{{$}}196; GCN-NEXT: no_stack_indirect_call:197; GCN-NEXT: .backend_stack_size: 0x10{{$}}198; GCN-NEXT: .lds_size: 0{{$}}199; GFX8-NEXT: .sgpr_count: 0x28{{$}}200; GFX9-NEXT: .sgpr_count: 0x2c{{$}}201; GCN-NEXT: .stack_frame_size_in_bytes: 0x10{{$}}202; GCN-NEXT: .vgpr_count: 0x2b{{$}}203; GCN-NEXT: simple_lds:204; GCN-NEXT: .backend_stack_size: 0{{$}}205; GCN-NEXT: .lds_size: 0x100{{$}}206; GCN-NEXT: .sgpr_count: 0x20{{$}}207; GCN-NEXT: .stack_frame_size_in_bytes: 0{{$}}208; GCN-NEXT: .vgpr_count: 0x1{{$}}209; GCN-NEXT: simple_lds_recurse:210; GCN-NEXT: .backend_stack_size: 0x10{{$}}211; GCN-NEXT: .lds_size: 0x100{{$}}212; GCN-NEXT: .sgpr_count: 0x28{{$}}213; GCN-NEXT: .stack_frame_size_in_bytes: 0x10{{$}}214; GCN-NEXT: .vgpr_count: 0x29{{$}}215; GCN-NEXT: simple_stack:216; GCN-NEXT: .backend_stack_size: 0x14{{$}}217; GCN-NEXT: .lds_size: 0{{$}}218; GCN-NEXT: .sgpr_count: 0x21{{$}}219; GCN-NEXT: .stack_frame_size_in_bytes: 0x14{{$}}220; GCN-NEXT: .vgpr_count: 0x2{{$}}221; GCN-NEXT: simple_stack_call:222; GCN-NEXT: .backend_stack_size: 0x20{{$}}223; GCN-NEXT: .lds_size: 0{{$}}224; GCN-NEXT: .sgpr_count: 0x25{{$}}225; GCN-NEXT: .stack_frame_size_in_bytes: 0x20{{$}}226; GCN-NEXT: .vgpr_count: 0x4{{$}}227; GCN-NEXT: simple_stack_extern_call:228; GCN-NEXT: .backend_stack_size: 0x20{{$}}229; GCN-NEXT: .lds_size: 0{{$}}230; GFX8-NEXT: .sgpr_count: 0x28{{$}}231; GFX9-NEXT: .sgpr_count: 0x2c{{$}}232; GCN-NEXT: .stack_frame_size_in_bytes: 0x20{{$}}233; GCN-NEXT: .vgpr_count: 0x2b{{$}}234; GCN-NEXT: simple_stack_indirect_call:235; GCN-NEXT: .backend_stack_size: 0x20{{$}}236; GCN-NEXT: .lds_size: 0{{$}}237; GFX8-NEXT: .sgpr_count: 0x28{{$}}238; GFX9-NEXT: .sgpr_count: 0x2c{{$}}239; GCN-NEXT: .stack_frame_size_in_bytes: 0x20{{$}}240; GCN-NEXT: .vgpr_count: 0x2b{{$}}241; GCN-NEXT: simple_stack_recurse:242; GCN-NEXT: .backend_stack_size: 0x20{{$}}243; GCN-NEXT: .lds_size: 0{{$}}244; GCN-NEXT: .sgpr_count: 0x28{{$}}245; GCN-NEXT: .stack_frame_size_in_bytes: 0x20{{$}}246; GCN-NEXT: .vgpr_count: 0x2a{{$}}247; GCN-NEXT: ...248