brintos

brintos / llvm-project-archived public Read only

0
0
Text · 29.1 KiB · 802de80 Raw
698 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefix=GCN %s3 4; Check that we properly realign the stack. While 4-byte access is all5; that is ever needed, some transformations rely on the known bits from the alignment of the pointer (e.g.6 7 8; 128 byte object9; 4 byte emergency stack slot10; = 144 bytes with padding between them11 12define void @needs_align16_default_stack_align(i32 %idx) #0 {13; GCN-LABEL: needs_align16_default_stack_align:14; GCN:       ; %bb.0:15; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)16; GCN-NEXT:    v_lshlrev_b32_e32 v0, 4, v017; GCN-NEXT:    v_lshrrev_b32_e64 v2, 6, s3218; GCN-NEXT:    v_add_u32_e32 v0, vcc, v0, v219; GCN-NEXT:    v_mov_b32_e32 v2, 120; GCN-NEXT:    v_mov_b32_e32 v1, 421; GCN-NEXT:    buffer_store_dword v2, v0, s[0:3], 0 offen22; GCN-NEXT:    s_waitcnt vmcnt(0)23; GCN-NEXT:    v_or_b32_e32 v2, 12, v024; GCN-NEXT:    buffer_store_dword v1, v2, s[0:3], 0 offen25; GCN-NEXT:    s_waitcnt vmcnt(0)26; GCN-NEXT:    v_or_b32_e32 v1, 8, v027; GCN-NEXT:    v_mov_b32_e32 v2, 328; GCN-NEXT:    buffer_store_dword v2, v1, s[0:3], 0 offen29; GCN-NEXT:    s_waitcnt vmcnt(0)30; GCN-NEXT:    v_or_b32_e32 v0, 4, v031; GCN-NEXT:    v_mov_b32_e32 v1, 232; GCN-NEXT:    buffer_store_dword v1, v0, s[0:3], 0 offen33; GCN-NEXT:    s_waitcnt vmcnt(0)34; GCN-NEXT:    s_setpc_b64 s[30:31]35; GCN: ; ScratchSize: 14436  %alloca.align16 = alloca [8 x <4 x i32>], align 16, addrspace(5)37  %gep0 = getelementptr inbounds [8 x <4 x i32>], ptr addrspace(5) %alloca.align16, i32 0, i32 %idx38  store volatile <4 x i32> <i32 1, i32 2, i32 3, i32 4>, ptr addrspace(5) %gep0, align 1639  ret void40}41 42define void @needs_align16_stack_align4(i32 %idx) #2 {43; GCN-LABEL: needs_align16_stack_align4:44; GCN:       ; %bb.0:45; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)46; GCN-NEXT:    s_mov_b32 s4, s3347; GCN-NEXT:    s_add_i32 s33, s32, 0x3c048; GCN-NEXT:    s_and_b32 s33, s33, 0xfffffc0049; GCN-NEXT:    v_lshlrev_b32_e32 v0, 4, v050; GCN-NEXT:    v_lshrrev_b32_e64 v2, 6, s3351; GCN-NEXT:    v_add_u32_e32 v0, vcc, v0, v252; GCN-NEXT:    v_mov_b32_e32 v2, 153; GCN-NEXT:    v_mov_b32_e32 v1, 454; GCN-NEXT:    buffer_store_dword v2, v0, s[0:3], 0 offen55; GCN-NEXT:    s_waitcnt vmcnt(0)56; GCN-NEXT:    v_or_b32_e32 v2, 12, v057; GCN-NEXT:    buffer_store_dword v1, v2, s[0:3], 0 offen58; GCN-NEXT:    s_waitcnt vmcnt(0)59; GCN-NEXT:    v_or_b32_e32 v1, 8, v060; GCN-NEXT:    v_mov_b32_e32 v2, 361; GCN-NEXT:    s_mov_b32 s5, s3462; GCN-NEXT:    s_mov_b32 s34, s3263; GCN-NEXT:    s_addk_i32 s32, 0x280064; GCN-NEXT:    buffer_store_dword v2, v1, s[0:3], 0 offen65; GCN-NEXT:    s_waitcnt vmcnt(0)66; GCN-NEXT:    v_or_b32_e32 v0, 4, v067; GCN-NEXT:    v_mov_b32_e32 v1, 268; GCN-NEXT:    buffer_store_dword v1, v0, s[0:3], 0 offen69; GCN-NEXT:    s_waitcnt vmcnt(0)70; GCN-NEXT:    s_mov_b32 s32, s3471; GCN-NEXT:    s_mov_b32 s34, s572; GCN-NEXT:    s_mov_b32 s33, s473; GCN-NEXT:    s_setpc_b64 s[30:31]74; GCN: ; ScratchSize: 16075  %alloca.align16 = alloca [8 x <4 x i32>], align 16, addrspace(5)76  %gep0 = getelementptr inbounds [8 x <4 x i32>], ptr addrspace(5) %alloca.align16, i32 0, i32 %idx77  store volatile <4 x i32> <i32 1, i32 2, i32 3, i32 4>, ptr addrspace(5) %gep0, align 1678  ret void79}80 81 82define void @needs_align32(i32 %idx) #0 {83; GCN-LABEL: needs_align32:84; GCN:       ; %bb.0:85; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)86; GCN-NEXT:    s_mov_b32 s4, s3387; GCN-NEXT:    s_add_i32 s33, s32, 0x7c088; GCN-NEXT:    s_and_b32 s33, s33, 0xfffff80089; GCN-NEXT:    v_lshlrev_b32_e32 v0, 4, v090; GCN-NEXT:    v_lshrrev_b32_e64 v2, 6, s3391; GCN-NEXT:    v_add_u32_e32 v0, vcc, v0, v292; GCN-NEXT:    v_mov_b32_e32 v2, 193; GCN-NEXT:    v_mov_b32_e32 v1, 494; GCN-NEXT:    buffer_store_dword v2, v0, s[0:3], 0 offen95; GCN-NEXT:    s_waitcnt vmcnt(0)96; GCN-NEXT:    v_or_b32_e32 v2, 12, v097; GCN-NEXT:    buffer_store_dword v1, v2, s[0:3], 0 offen98; GCN-NEXT:    s_waitcnt vmcnt(0)99; GCN-NEXT:    v_or_b32_e32 v1, 8, v0100; GCN-NEXT:    v_mov_b32_e32 v2, 3101; GCN-NEXT:    s_mov_b32 s5, s34102; GCN-NEXT:    s_mov_b32 s34, s32103; GCN-NEXT:    s_addk_i32 s32, 0x3000104; GCN-NEXT:    buffer_store_dword v2, v1, s[0:3], 0 offen105; GCN-NEXT:    s_waitcnt vmcnt(0)106; GCN-NEXT:    v_or_b32_e32 v0, 4, v0107; GCN-NEXT:    v_mov_b32_e32 v1, 2108; GCN-NEXT:    buffer_store_dword v1, v0, s[0:3], 0 offen109; GCN-NEXT:    s_waitcnt vmcnt(0)110; GCN-NEXT:    s_mov_b32 s32, s34111; GCN-NEXT:    s_mov_b32 s34, s5112; GCN-NEXT:    s_mov_b32 s33, s4113; GCN-NEXT:    s_setpc_b64 s[30:31]114; GCN: ; ScratchSize: 192115  %alloca.align16 = alloca [8 x <4 x i32>], align 32, addrspace(5)116  %gep0 = getelementptr inbounds [8 x <4 x i32>], ptr addrspace(5) %alloca.align16, i32 0, i32 %idx117  store volatile <4 x i32> <i32 1, i32 2, i32 3, i32 4>, ptr addrspace(5) %gep0, align 32118  ret void119}120 121define void @force_realign4(i32 %idx) #1 {122; GCN-LABEL: force_realign4:123; GCN:       ; %bb.0:124; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)125; GCN-NEXT:    s_mov_b32 s4, s33126; GCN-NEXT:    s_add_i32 s33, s32, 0xc0127; GCN-NEXT:    s_and_b32 s33, s33, 0xffffff00128; GCN-NEXT:    v_lshlrev_b32_e32 v0, 2, v0129; GCN-NEXT:    v_lshrrev_b32_e64 v1, 6, s33130; GCN-NEXT:    s_mov_b32 s5, s34131; GCN-NEXT:    s_mov_b32 s34, s32132; GCN-NEXT:    s_addk_i32 s32, 0xd00133; GCN-NEXT:    v_add_u32_e32 v0, vcc, v0, v1134; GCN-NEXT:    v_mov_b32_e32 v1, 3135; GCN-NEXT:    buffer_store_dword v1, v0, s[0:3], 0 offen136; GCN-NEXT:    s_waitcnt vmcnt(0)137; GCN-NEXT:    s_mov_b32 s32, s34138; GCN-NEXT:    s_mov_b32 s34, s5139; GCN-NEXT:    s_mov_b32 s33, s4140; GCN-NEXT:    s_setpc_b64 s[30:31]141; GCN: ; ScratchSize: 52142  %alloca.align16 = alloca [8 x i32], align 4, addrspace(5)143  %gep0 = getelementptr inbounds [8 x i32], ptr addrspace(5) %alloca.align16, i32 0, i32 %idx144  store volatile i32 3, ptr addrspace(5) %gep0, align 4145  ret void146}147 148define amdgpu_kernel void @kernel_call_align16_from_8() #0 {149; GCN-LABEL: kernel_call_align16_from_8:150; GCN:       ; %bb.0:151; GCN-NEXT:    s_add_i32 s12, s12, s17152; GCN-NEXT:    s_lshr_b32 flat_scratch_hi, s12, 8153; GCN-NEXT:    s_add_u32 s0, s0, s17154; GCN-NEXT:    s_addc_u32 s1, s1, 0155; GCN-NEXT:    s_mov_b32 flat_scratch_lo, s13156; GCN-NEXT:    s_mov_b32 s13, s15157; GCN-NEXT:    s_mov_b32 s12, s14158; GCN-NEXT:    s_getpc_b64 s[14:15]159; GCN-NEXT:    s_add_u32 s14, s14, needs_align16_default_stack_align@gotpcrel32@lo+4160; GCN-NEXT:    s_addc_u32 s15, s15, needs_align16_default_stack_align@gotpcrel32@hi+12161; GCN-NEXT:    s_load_dwordx2 s[18:19], s[14:15], 0x0162; GCN-NEXT:    v_lshlrev_b32_e32 v1, 10, v1163; GCN-NEXT:    v_lshlrev_b32_e32 v2, 20, v2164; GCN-NEXT:    v_or_b32_e32 v0, v0, v1165; GCN-NEXT:    v_mov_b32_e32 v3, 2166; GCN-NEXT:    v_or_b32_e32 v31, v0, v2167; GCN-NEXT:    s_mov_b32 s14, s16168; GCN-NEXT:    v_mov_b32_e32 v0, 1169; GCN-NEXT:    s_movk_i32 s32, 0x400170; GCN-NEXT:    buffer_store_dword v3, off, s[0:3], 0171; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)172; GCN-NEXT:    s_swappc_b64 s[30:31], s[18:19]173; GCN-NEXT:    s_endpgm174  %alloca = alloca i32, align 4, addrspace(5)175  store volatile i32 2, ptr addrspace(5) %alloca176  call void @needs_align16_default_stack_align(i32 1)177  ret void178}179 180; The call sequence should keep the stack on call aligned to 4181define amdgpu_kernel void @kernel_call_align16_from_5() {182; GCN-LABEL: kernel_call_align16_from_5:183; GCN:       ; %bb.0:184; GCN-NEXT:    s_add_i32 s12, s12, s17185; GCN-NEXT:    s_lshr_b32 flat_scratch_hi, s12, 8186; GCN-NEXT:    s_add_u32 s0, s0, s17187; GCN-NEXT:    s_addc_u32 s1, s1, 0188; GCN-NEXT:    s_mov_b32 flat_scratch_lo, s13189; GCN-NEXT:    s_mov_b32 s13, s15190; GCN-NEXT:    s_mov_b32 s12, s14191; GCN-NEXT:    s_getpc_b64 s[14:15]192; GCN-NEXT:    s_add_u32 s14, s14, needs_align16_default_stack_align@gotpcrel32@lo+4193; GCN-NEXT:    s_addc_u32 s15, s15, needs_align16_default_stack_align@gotpcrel32@hi+12194; GCN-NEXT:    s_load_dwordx2 s[18:19], s[14:15], 0x0195; GCN-NEXT:    v_lshlrev_b32_e32 v1, 10, v1196; GCN-NEXT:    v_lshlrev_b32_e32 v2, 20, v2197; GCN-NEXT:    v_or_b32_e32 v0, v0, v1198; GCN-NEXT:    v_mov_b32_e32 v3, 2199; GCN-NEXT:    v_or_b32_e32 v31, v0, v2200; GCN-NEXT:    s_mov_b32 s14, s16201; GCN-NEXT:    v_mov_b32_e32 v0, 1202; GCN-NEXT:    s_movk_i32 s32, 0x400203; GCN-NEXT:    buffer_store_byte v3, off, s[0:3], 0204; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)205; GCN-NEXT:    s_swappc_b64 s[30:31], s[18:19]206; GCN-NEXT:    s_endpgm207  %alloca0 = alloca i8, align 1, addrspace(5)208  store volatile i8 2, ptr  addrspace(5) %alloca0209 210  call void @needs_align16_default_stack_align(i32 1)211  ret void212}213 214define amdgpu_kernel void @kernel_call_align4_from_5() {215; GCN-LABEL: kernel_call_align4_from_5:216; GCN:       ; %bb.0:217; GCN-NEXT:    s_add_i32 s12, s12, s17218; GCN-NEXT:    s_lshr_b32 flat_scratch_hi, s12, 8219; GCN-NEXT:    s_add_u32 s0, s0, s17220; GCN-NEXT:    s_addc_u32 s1, s1, 0221; GCN-NEXT:    s_mov_b32 flat_scratch_lo, s13222; GCN-NEXT:    s_mov_b32 s13, s15223; GCN-NEXT:    s_mov_b32 s12, s14224; GCN-NEXT:    s_getpc_b64 s[14:15]225; GCN-NEXT:    s_add_u32 s14, s14, needs_align16_stack_align4@gotpcrel32@lo+4226; GCN-NEXT:    s_addc_u32 s15, s15, needs_align16_stack_align4@gotpcrel32@hi+12227; GCN-NEXT:    s_load_dwordx2 s[18:19], s[14:15], 0x0228; GCN-NEXT:    v_lshlrev_b32_e32 v1, 10, v1229; GCN-NEXT:    v_lshlrev_b32_e32 v2, 20, v2230; GCN-NEXT:    v_or_b32_e32 v0, v0, v1231; GCN-NEXT:    v_mov_b32_e32 v3, 2232; GCN-NEXT:    v_or_b32_e32 v31, v0, v2233; GCN-NEXT:    s_mov_b32 s14, s16234; GCN-NEXT:    v_mov_b32_e32 v0, 1235; GCN-NEXT:    s_movk_i32 s32, 0x400236; GCN-NEXT:    buffer_store_byte v3, off, s[0:3], 0237; GCN-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)238; GCN-NEXT:    s_swappc_b64 s[30:31], s[18:19]239; GCN-NEXT:    s_endpgm240  %alloca0 = alloca i8, align 1, addrspace(5)241  store volatile i8 2, ptr  addrspace(5) %alloca0242 243  call void @needs_align16_stack_align4(i32 1)244  ret void245}246 247define void @default_realign_align128(i32 %idx) #0 {248; GCN-LABEL: default_realign_align128:249; GCN:       ; %bb.0:250; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)251; GCN-NEXT:    s_mov_b32 s4, s33252; GCN-NEXT:    s_add_i32 s33, s32, 0x1fc0253; GCN-NEXT:    s_and_b32 s33, s33, 0xffffe000254; GCN-NEXT:    s_mov_b32 s5, s34255; GCN-NEXT:    s_mov_b32 s34, s32256; GCN-NEXT:    s_addk_i32 s32, 0x4000257; GCN-NEXT:    v_mov_b32_e32 v0, 9258; GCN-NEXT:    buffer_store_dword v0, off, s[0:3], s33259; GCN-NEXT:    s_waitcnt vmcnt(0)260; GCN-NEXT:    s_mov_b32 s32, s34261; GCN-NEXT:    s_mov_b32 s34, s5262; GCN-NEXT:    s_mov_b32 s33, s4263; GCN-NEXT:    s_setpc_b64 s[30:31]264  %alloca.align = alloca i32, align 128, addrspace(5)265  store volatile i32 9, ptr addrspace(5) %alloca.align, align 128266  ret void267}268 269define void @disable_realign_align128(i32 %idx) #3 {270; GCN-LABEL: disable_realign_align128:271; GCN:       ; %bb.0:272; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)273; GCN-NEXT:    v_mov_b32_e32 v0, 9274; GCN-NEXT:    buffer_store_dword v0, off, s[0:3], s32275; GCN-NEXT:    s_waitcnt vmcnt(0)276; GCN-NEXT:    s_setpc_b64 s[30:31]277  %alloca.align = alloca i32, align 128, addrspace(5)278  store volatile i32 9, ptr addrspace(5) %alloca.align, align 128279  ret void280}281 282declare void @extern_func(<32 x i32>, i32) #0283define void @func_call_align1024_bp_gets_vgpr_spill(<32 x i32> %a, i32 %b) #0 {284; The test forces the stack to be realigned to a new boundary285; since there is a local object with an alignment of 1024.286; Should use BP to access the incoming stack arguments.287; The BP value is saved/restored with a VGPR spill.288; GCN-LABEL: func_call_align1024_bp_gets_vgpr_spill:289; GCN:       ; %bb.0:290; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)291; GCN-NEXT:    s_mov_b32 s16, s33292; GCN-NEXT:    s_add_i32 s33, s32, 0xffc0293; GCN-NEXT:    s_and_b32 s33, s33, 0xffff0000294; GCN-NEXT:    s_or_saveexec_b64 s[18:19], -1295; GCN-NEXT:    buffer_store_dword v40, off, s[0:3], s33 offset:1028 ; 4-byte Folded Spill296; GCN-NEXT:    s_mov_b64 exec, s[18:19]297; GCN-NEXT:    v_writelane_b32 v40, s16, 2298; GCN-NEXT:    v_writelane_b32 v40, s34, 3299; GCN-NEXT:    s_mov_b32 s34, s32300; GCN-NEXT:    v_mov_b32_e32 v32, 0301; GCN-NEXT:    buffer_store_dword v32, off, s[0:3], s33 offset:1024302; GCN-NEXT:    s_waitcnt vmcnt(0)303; GCN-NEXT:    buffer_load_dword v32, off, s[0:3], s34304; GCN-NEXT:    buffer_load_dword v33, off, s[0:3], s34 offset:4305; GCN-NEXT:    s_add_i32 s32, s32, 0x30000306; GCN-NEXT:    s_getpc_b64 s[16:17]307; GCN-NEXT:    s_add_u32 s16, s16, extern_func@gotpcrel32@lo+4308; GCN-NEXT:    s_addc_u32 s17, s17, extern_func@gotpcrel32@hi+12309; GCN-NEXT:    s_load_dwordx2 s[16:17], s[16:17], 0x0310; GCN-NEXT:    v_writelane_b32 v40, s30, 0311; GCN-NEXT:    v_writelane_b32 v40, s31, 1312; GCN-NEXT:    s_waitcnt vmcnt(1)313; GCN-NEXT:    buffer_store_dword v32, off, s[0:3], s32314; GCN-NEXT:    s_waitcnt vmcnt(1)315; GCN-NEXT:    buffer_store_dword v33, off, s[0:3], s32 offset:4316; GCN-NEXT:    s_waitcnt lgkmcnt(0)317; GCN-NEXT:    s_swappc_b64 s[30:31], s[16:17]318; GCN-NEXT:    v_readlane_b32 s31, v40, 1319; GCN-NEXT:    v_readlane_b32 s30, v40, 0320; GCN-NEXT:    s_mov_b32 s32, s34321; GCN-NEXT:    v_readlane_b32 s4, v40, 2322; GCN-NEXT:    v_readlane_b32 s34, v40, 3323; GCN-NEXT:    s_or_saveexec_b64 s[6:7], -1324; GCN-NEXT:    buffer_load_dword v40, off, s[0:3], s33 offset:1028 ; 4-byte Folded Reload325; GCN-NEXT:    s_mov_b64 exec, s[6:7]326; GCN-NEXT:    s_mov_b32 s33, s4327; GCN-NEXT:    s_waitcnt vmcnt(0)328; GCN-NEXT:    s_setpc_b64 s[30:31]329 330  %temp = alloca i32, align 1024, addrspace(5)331  store volatile i32 0, ptr addrspace(5) %temp, align 1024332  call void @extern_func(<32 x i32> %a, i32 %b)333  ret void334}335 336%struct.Data = type { [9 x i32] }337define i32 @needs_align1024_stack_args_used_inside_loop(ptr addrspace(5) nocapture readonly byval(%struct.Data) align 8 %arg) local_unnamed_addr #4 {338; The local object allocation needed an alignment of 1024.339; Since the function argument is accessed in a loop with an340; index variable, the base pointer first get loaded into a VGPR341; and that value should be further referenced to load the incoming values.342; The BP value will get saved/restored in an SGPR at the prolgoue/epilogue.343; GCN-LABEL: needs_align1024_stack_args_used_inside_loop:344; GCN:       ; %bb.0: ; %begin345; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)346; GCN-NEXT:    s_mov_b32 s11, s33347; GCN-NEXT:    s_add_i32 s33, s32, 0xffc0348; GCN-NEXT:    s_mov_b32 s14, s34349; GCN-NEXT:    s_mov_b32 s34, s32350; GCN-NEXT:    s_and_b32 s33, s33, 0xffff0000351; GCN-NEXT:    v_lshrrev_b32_e64 v1, 6, s34352; GCN-NEXT:    v_mov_b32_e32 v0, 0353; GCN-NEXT:    s_mov_b32 s10, 0354; GCN-NEXT:    s_mov_b64 s[4:5], 0355; GCN-NEXT:    s_add_i32 s32, s32, 0x30000356; GCN-NEXT:    buffer_store_dword v0, off, s[0:3], s33 offset:1024357; GCN-NEXT:    s_waitcnt vmcnt(0)358; GCN-NEXT:    ; implicit-def: $sgpr6_sgpr7359; GCN-NEXT:    s_branch .LBB10_2360; GCN-NEXT:  .LBB10_1: ; %Flow361; GCN-NEXT:    ; in Loop: Header=BB10_2 Depth=1362; GCN-NEXT:    s_or_b64 exec, exec, s[8:9]363; GCN-NEXT:    s_and_b64 s[8:9], exec, s[6:7]364; GCN-NEXT:    s_or_b64 s[4:5], s[8:9], s[4:5]365; GCN-NEXT:    s_andn2_b64 exec, exec, s[4:5]366; GCN-NEXT:    s_cbranch_execz .LBB10_4367; GCN-NEXT:  .LBB10_2: ; %loop_body368; GCN-NEXT:    ; =>This Inner Loop Header: Depth=1369; GCN-NEXT:    buffer_load_dword v0, v1, s[0:3], 0 offen370; GCN-NEXT:    s_or_b64 s[6:7], s[6:7], exec371; GCN-NEXT:    s_waitcnt vmcnt(0)372; GCN-NEXT:    v_cmp_eq_u32_e32 vcc, s10, v0373; GCN-NEXT:    v_mov_b32_e32 v0, 0374; GCN-NEXT:    s_and_saveexec_b64 s[8:9], vcc375; GCN-NEXT:    s_cbranch_execz .LBB10_1376; GCN-NEXT:  ; %bb.3: ; %loop_end377; GCN-NEXT:    ; in Loop: Header=BB10_2 Depth=1378; GCN-NEXT:    s_add_i32 s10, s10, 1379; GCN-NEXT:    s_cmp_eq_u32 s10, 9380; GCN-NEXT:    s_cselect_b64 s[12:13], -1, 0381; GCN-NEXT:    s_andn2_b64 s[6:7], s[6:7], exec382; GCN-NEXT:    s_and_b64 s[12:13], s[12:13], exec383; GCN-NEXT:    v_add_u32_e32 v1, vcc, 4, v1384; GCN-NEXT:    v_mov_b32_e32 v0, 1385; GCN-NEXT:    s_or_b64 s[6:7], s[6:7], s[12:13]386; GCN-NEXT:    s_branch .LBB10_1387; GCN-NEXT:  .LBB10_4: ; %exit388; GCN-NEXT:    s_or_b64 exec, exec, s[4:5]389; GCN-NEXT:    s_mov_b32 s32, s34390; GCN-NEXT:    s_mov_b32 s34, s14391; GCN-NEXT:    s_mov_b32 s33, s11392; GCN-NEXT:    s_setpc_b64 s[30:31]393begin:394  %local_var = alloca i32, align 1024, addrspace(5)395  store volatile i32 0, ptr addrspace(5) %local_var, align 1024396  br label %loop_body397 398loop_end:                                                ; preds = %loop_body399  %idx_next = add nuw nsw i32 %lp_idx, 1400  %lp_exit_cond = icmp eq i32 %idx_next, 9401  br i1 %lp_exit_cond, label %exit, label %loop_body402 403loop_body:                                                ; preds = %loop_end, %begin404  %lp_idx = phi i32 [ 0, %begin ], [ %idx_next, %loop_end ]405  %ptr = getelementptr inbounds %struct.Data, ptr addrspace(5) %arg, i32 0, i32 0, i32 %lp_idx406  %val = load i32, ptr addrspace(5) %ptr, align 8407  %lp_cond = icmp eq i32 %val, %lp_idx408  br i1 %lp_cond, label %loop_end, label %exit409 410exit:                                               ; preds = %loop_end, %loop_body411  %out = phi i32 [ 0, %loop_body ], [ 1, %loop_end ]412  ret i32 %out413}414 415define void @no_free_scratch_sgpr_for_bp_copy(<32 x i32> %a, i32 %b) #0 {416; GCN-LABEL: no_free_scratch_sgpr_for_bp_copy:417; GCN:       ; %bb.0:418; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)419; GCN-NEXT:    s_mov_b32 s41, s34420; GCN-NEXT:    s_mov_b32 s34, s32421; GCN-NEXT:    buffer_load_dword v0, off, s[0:3], s34 offset:4422; GCN-NEXT:    s_mov_b32 s40, s33423; GCN-NEXT:    s_add_i32 s33, s32, 0x1fc0424; GCN-NEXT:    s_and_b32 s33, s33, 0xffffe000425; GCN-NEXT:    s_addk_i32 s32, 0x6000426; GCN-NEXT:    s_mov_b32 s32, s34427; GCN-NEXT:    s_mov_b32 s34, s41428; GCN-NEXT:    s_waitcnt vmcnt(0)429; GCN-NEXT:    buffer_store_dword v0, off, s[0:3], s33 offset:128430; GCN-NEXT:    s_waitcnt vmcnt(0)431; GCN-NEXT:    ;;#ASMSTART432; GCN-NEXT:    ;;#ASMEND433; GCN-NEXT:    s_mov_b32 s33, s40434; GCN-NEXT:    s_setpc_b64 s[30:31]435  %local_val = alloca i32, align 128, addrspace(5)436  store volatile i32 %b, ptr addrspace(5) %local_val, align 128437  ; Use all clobberable registers, so BP has to spill to a VGPR.438  call void asm sideeffect "",439    "~{s0},~{s1},~{s2},~{s3},~{s4},~{s5},~{s6},~{s7},~{s8},~{s9}440    ,~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},~{s16},~{s17},~{s18},~{s19}441    ,~{s20},~{s21},~{s22},~{s23},~{s24},~{s25},~{s26},~{s27},~{s28},~{s29}442    ,~{vcc_hi}"() #0443  ret void444}445 446define void @no_free_regs_spill_bp_to_memory(<32 x i32> %a, i32 %b) #5 {447; If there are no free SGPRs or VGPRs available we must spill the BP to memory.448; GCN-LABEL: no_free_regs_spill_bp_to_memory:449; GCN:       ; %bb.0:450; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)451; GCN-NEXT:    s_mov_b32 s4, s33452; GCN-NEXT:    s_add_i32 s33, s32, 0x1fc0453; GCN-NEXT:    s_and_b32 s33, s33, 0xffffe000454; GCN-NEXT:    s_xor_saveexec_b64 s[6:7], -1455; GCN-NEXT:    buffer_store_dword v39, off, s[0:3], s33 offset:132 ; 4-byte Folded Spill456; GCN-NEXT:    s_mov_b64 exec, s[6:7]457; GCN-NEXT:    v_writelane_b32 v39, s4, 32458; GCN-NEXT:    v_writelane_b32 v39, s34, 33459; GCN-NEXT:    s_mov_b32 s34, s32460; GCN-NEXT:    buffer_load_dword v0, off, s[0:3], s34 offset:4461; GCN-NEXT:    v_writelane_b32 v39, s39, 0462; GCN-NEXT:    v_writelane_b32 v39, s48, 1463; GCN-NEXT:    v_writelane_b32 v39, s49, 2464; GCN-NEXT:    v_writelane_b32 v39, s50, 3465; GCN-NEXT:    v_writelane_b32 v39, s51, 4466; GCN-NEXT:    v_writelane_b32 v39, s52, 5467; GCN-NEXT:    v_writelane_b32 v39, s53, 6468; GCN-NEXT:    v_writelane_b32 v39, s54, 7469; GCN-NEXT:    v_writelane_b32 v39, s55, 8470; GCN-NEXT:    v_writelane_b32 v39, s64, 9471; GCN-NEXT:    v_writelane_b32 v39, s65, 10472; GCN-NEXT:    v_writelane_b32 v39, s66, 11473; GCN-NEXT:    v_writelane_b32 v39, s67, 12474; GCN-NEXT:    v_writelane_b32 v39, s68, 13475; GCN-NEXT:    v_writelane_b32 v39, s69, 14476; GCN-NEXT:    v_writelane_b32 v39, s70, 15477; GCN-NEXT:    v_writelane_b32 v39, s71, 16478; GCN-NEXT:    v_writelane_b32 v39, s80, 17479; GCN-NEXT:    v_writelane_b32 v39, s81, 18480; GCN-NEXT:    v_writelane_b32 v39, s82, 19481; GCN-NEXT:    v_writelane_b32 v39, s83, 20482; GCN-NEXT:    v_writelane_b32 v39, s84, 21483; GCN-NEXT:    v_writelane_b32 v39, s85, 22484; GCN-NEXT:    v_writelane_b32 v39, s86, 23485; GCN-NEXT:    v_writelane_b32 v39, s87, 24486; GCN-NEXT:    v_writelane_b32 v39, s96, 25487; GCN-NEXT:    v_writelane_b32 v39, s97, 26488; GCN-NEXT:    v_writelane_b32 v39, s98, 27489; GCN-NEXT:    v_writelane_b32 v39, s99, 28490; GCN-NEXT:    v_writelane_b32 v39, s100, 29491; GCN-NEXT:    v_writelane_b32 v39, s101, 30492; GCN-NEXT:    s_addk_i32 s32, 0x6000493; GCN-NEXT:    v_writelane_b32 v39, s102, 31494; GCN-NEXT:    s_mov_b32 s32, s34495; GCN-NEXT:    v_readlane_b32 s34, v39, 33496; GCN-NEXT:    s_waitcnt vmcnt(0)497; GCN-NEXT:    buffer_store_dword v0, off, s[0:3], s33 offset:128498; GCN-NEXT:    s_waitcnt vmcnt(0)499; GCN-NEXT:    ;;#ASMSTART500; GCN-NEXT:    ; clobber nonpreserved SGPRs and 64 CSRs501; GCN-NEXT:    ;;#ASMEND502; GCN-NEXT:    ;;#ASMSTART503; GCN-NEXT:    ; clobber all VGPRs504; GCN-NEXT:    ;;#ASMEND505; GCN-NEXT:    v_readlane_b32 s102, v39, 31506; GCN-NEXT:    v_readlane_b32 s101, v39, 30507; GCN-NEXT:    v_readlane_b32 s100, v39, 29508; GCN-NEXT:    v_readlane_b32 s99, v39, 28509; GCN-NEXT:    v_readlane_b32 s98, v39, 27510; GCN-NEXT:    v_readlane_b32 s97, v39, 26511; GCN-NEXT:    v_readlane_b32 s96, v39, 25512; GCN-NEXT:    v_readlane_b32 s87, v39, 24513; GCN-NEXT:    v_readlane_b32 s86, v39, 23514; GCN-NEXT:    v_readlane_b32 s85, v39, 22515; GCN-NEXT:    v_readlane_b32 s84, v39, 21516; GCN-NEXT:    v_readlane_b32 s83, v39, 20517; GCN-NEXT:    v_readlane_b32 s82, v39, 19518; GCN-NEXT:    v_readlane_b32 s81, v39, 18519; GCN-NEXT:    v_readlane_b32 s80, v39, 17520; GCN-NEXT:    v_readlane_b32 s71, v39, 16521; GCN-NEXT:    v_readlane_b32 s70, v39, 15522; GCN-NEXT:    v_readlane_b32 s69, v39, 14523; GCN-NEXT:    v_readlane_b32 s68, v39, 13524; GCN-NEXT:    v_readlane_b32 s67, v39, 12525; GCN-NEXT:    v_readlane_b32 s66, v39, 11526; GCN-NEXT:    v_readlane_b32 s65, v39, 10527; GCN-NEXT:    v_readlane_b32 s64, v39, 9528; GCN-NEXT:    v_readlane_b32 s55, v39, 8529; GCN-NEXT:    v_readlane_b32 s54, v39, 7530; GCN-NEXT:    v_readlane_b32 s53, v39, 6531; GCN-NEXT:    v_readlane_b32 s52, v39, 5532; GCN-NEXT:    v_readlane_b32 s51, v39, 4533; GCN-NEXT:    v_readlane_b32 s50, v39, 3534; GCN-NEXT:    v_readlane_b32 s49, v39, 2535; GCN-NEXT:    v_readlane_b32 s48, v39, 1536; GCN-NEXT:    v_readlane_b32 s39, v39, 0537; GCN-NEXT:    v_readlane_b32 s4, v39, 32538; GCN-NEXT:    s_xor_saveexec_b64 s[6:7], -1539; GCN-NEXT:    buffer_load_dword v39, off, s[0:3], s33 offset:132 ; 4-byte Folded Reload540; GCN-NEXT:    s_mov_b64 exec, s[6:7]541; GCN-NEXT:    s_mov_b32 s33, s4542; GCN-NEXT:    s_waitcnt vmcnt(0)543; GCN-NEXT:    s_setpc_b64 s[30:31]544  %local_val = alloca i32, align 128, addrspace(5)545  store volatile i32 %b, ptr addrspace(5) %local_val, align 128546 547  call void asm sideeffect "; clobber nonpreserved SGPRs and 64 CSRs",548    "~{s4},~{s5},~{s6},~{s7},~{s8},~{s9}549    ,~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},~{s16},~{s17},~{s18},~{s19}550    ,~{s20},~{s21},~{s22},~{s23},~{s24},~{s25},~{s26},~{s27},~{s28},~{s29}551    ,~{s40},~{s41},~{s42},~{s43},~{s44},~{s45},~{s46},~{s47},~{s48},~{s49}552    ,~{s50},~{s51},~{s52},~{s53},~{s54},~{s55},~{s56},~{s57},~{s58},~{s59}553    ,~{s60},~{s61},~{s62},~{s63},~{s64},~{s65},~{s66},~{s67},~{s68},~{s69}554    ,~{s70},~{s71},~{s72},~{s73},~{s74},~{s75},~{s76},~{s77},~{s78},~{s79}555    ,~{s80},~{s81},~{s82},~{s83},~{s84},~{s85},~{s86},~{s87},~{s88},~{s89}556    ,~{s90},~{s91},~{s92},~{s93},~{s94},~{s95},~{s96},~{s97},~{s98},~{s99}557    ,~{s100},~{s101},~{s102},~{s39},~{vcc}"() #0558 559  call void asm sideeffect "; clobber all VGPRs",560    "~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9}561    ,~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19}562    ,~{v20},~{v21},~{v22},~{v23},~{v24},~{v25},~{v26},~{v27},~{v28},~{v29}563    ,~{v30},~{v31},~{v32},~{v33},~{v34},~{v35},~{v36},~{v37},~{v38}" () #0564  ret void565}566 567define void @spill_bp_to_memory_scratch_reg_needed_mubuf_offset(<32 x i32> %a, i32 %b, ptr addrspace(5) byval([4096 x i8]) align 4 %arg) #5 {568; If the size of the offset exceeds the MUBUF offset field we need another569; scratch VGPR to hold the offset.570; GCN-LABEL: spill_bp_to_memory_scratch_reg_needed_mubuf_offset:571; GCN:       ; %bb.0:572; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)573; GCN-NEXT:    s_mov_b32 s4, s33574; GCN-NEXT:    s_add_i32 s33, s32, 0x1fc0575; GCN-NEXT:    s_and_b32 s33, s33, 0xffffe000576; GCN-NEXT:    s_xor_saveexec_b64 s[6:7], -1577; GCN-NEXT:    s_add_i32 s5, s33, 0x42100578; GCN-NEXT:    buffer_store_dword v39, off, s[0:3], s5 ; 4-byte Folded Spill579; GCN-NEXT:    s_mov_b64 exec, s[6:7]580; GCN-NEXT:    v_writelane_b32 v39, s4, 32581; GCN-NEXT:    v_writelane_b32 v39, s34, 33582; GCN-NEXT:    s_mov_b32 s34, s32583; GCN-NEXT:    buffer_load_dword v0, off, s[0:3], s34 offset:4584; GCN-NEXT:    v_writelane_b32 v39, s39, 0585; GCN-NEXT:    v_writelane_b32 v39, s48, 1586; GCN-NEXT:    v_writelane_b32 v39, s49, 2587; GCN-NEXT:    v_writelane_b32 v39, s50, 3588; GCN-NEXT:    v_writelane_b32 v39, s51, 4589; GCN-NEXT:    v_writelane_b32 v39, s52, 5590; GCN-NEXT:    v_writelane_b32 v39, s53, 6591; GCN-NEXT:    v_writelane_b32 v39, s54, 7592; GCN-NEXT:    v_writelane_b32 v39, s55, 8593; GCN-NEXT:    v_writelane_b32 v39, s64, 9594; GCN-NEXT:    v_writelane_b32 v39, s65, 10595; GCN-NEXT:    v_writelane_b32 v39, s66, 11596; GCN-NEXT:    v_writelane_b32 v39, s67, 12597; GCN-NEXT:    v_writelane_b32 v39, s68, 13598; GCN-NEXT:    v_writelane_b32 v39, s69, 14599; GCN-NEXT:    v_writelane_b32 v39, s70, 15600; GCN-NEXT:    v_writelane_b32 v39, s71, 16601; GCN-NEXT:    v_writelane_b32 v39, s80, 17602; GCN-NEXT:    v_writelane_b32 v39, s81, 18603; GCN-NEXT:    v_writelane_b32 v39, s82, 19604; GCN-NEXT:    v_writelane_b32 v39, s83, 20605; GCN-NEXT:    v_writelane_b32 v39, s84, 21606; GCN-NEXT:    v_writelane_b32 v39, s85, 22607; GCN-NEXT:    v_writelane_b32 v39, s86, 23608; GCN-NEXT:    v_writelane_b32 v39, s87, 24609; GCN-NEXT:    v_writelane_b32 v39, s96, 25610; GCN-NEXT:    v_writelane_b32 v39, s97, 26611; GCN-NEXT:    v_writelane_b32 v39, s98, 27612; GCN-NEXT:    v_writelane_b32 v39, s99, 28613; GCN-NEXT:    v_writelane_b32 v39, s100, 29614; GCN-NEXT:    v_writelane_b32 v39, s101, 30615; GCN-NEXT:    v_mov_b32_e32 v1, 0x1080616; GCN-NEXT:    s_add_i32 s32, s32, 0x46000617; GCN-NEXT:    v_writelane_b32 v39, s102, 31618; GCN-NEXT:    s_mov_b32 s32, s34619; GCN-NEXT:    v_readlane_b32 s34, v39, 33620; GCN-NEXT:    s_waitcnt vmcnt(0)621; GCN-NEXT:    buffer_store_dword v0, v1, s[0:3], s33 offen622; GCN-NEXT:    s_waitcnt vmcnt(0)623; GCN-NEXT:    ;;#ASMSTART624; GCN-NEXT:    ; clobber nonpreserved SGPRs and 64 CSRs625; GCN-NEXT:    ;;#ASMEND626; GCN-NEXT:    ;;#ASMSTART627; GCN-NEXT:    ; clobber all VGPRs628; GCN-NEXT:    ;;#ASMEND629; GCN-NEXT:    v_readlane_b32 s102, v39, 31630; GCN-NEXT:    v_readlane_b32 s101, v39, 30631; GCN-NEXT:    v_readlane_b32 s100, v39, 29632; GCN-NEXT:    v_readlane_b32 s99, v39, 28633; GCN-NEXT:    v_readlane_b32 s98, v39, 27634; GCN-NEXT:    v_readlane_b32 s97, v39, 26635; GCN-NEXT:    v_readlane_b32 s96, v39, 25636; GCN-NEXT:    v_readlane_b32 s87, v39, 24637; GCN-NEXT:    v_readlane_b32 s86, v39, 23638; GCN-NEXT:    v_readlane_b32 s85, v39, 22639; GCN-NEXT:    v_readlane_b32 s84, v39, 21640; GCN-NEXT:    v_readlane_b32 s83, v39, 20641; GCN-NEXT:    v_readlane_b32 s82, v39, 19642; GCN-NEXT:    v_readlane_b32 s81, v39, 18643; GCN-NEXT:    v_readlane_b32 s80, v39, 17644; GCN-NEXT:    v_readlane_b32 s71, v39, 16645; GCN-NEXT:    v_readlane_b32 s70, v39, 15646; GCN-NEXT:    v_readlane_b32 s69, v39, 14647; GCN-NEXT:    v_readlane_b32 s68, v39, 13648; GCN-NEXT:    v_readlane_b32 s67, v39, 12649; GCN-NEXT:    v_readlane_b32 s66, v39, 11650; GCN-NEXT:    v_readlane_b32 s65, v39, 10651; GCN-NEXT:    v_readlane_b32 s64, v39, 9652; GCN-NEXT:    v_readlane_b32 s55, v39, 8653; GCN-NEXT:    v_readlane_b32 s54, v39, 7654; GCN-NEXT:    v_readlane_b32 s53, v39, 6655; GCN-NEXT:    v_readlane_b32 s52, v39, 5656; GCN-NEXT:    v_readlane_b32 s51, v39, 4657; GCN-NEXT:    v_readlane_b32 s50, v39, 3658; GCN-NEXT:    v_readlane_b32 s49, v39, 2659; GCN-NEXT:    v_readlane_b32 s48, v39, 1660; GCN-NEXT:    v_readlane_b32 s39, v39, 0661; GCN-NEXT:    v_readlane_b32 s4, v39, 32662; GCN-NEXT:    s_xor_saveexec_b64 s[6:7], -1663; GCN-NEXT:    s_add_i32 s5, s33, 0x42100664; GCN-NEXT:    buffer_load_dword v39, off, s[0:3], s5 ; 4-byte Folded Reload665; GCN-NEXT:    s_mov_b64 exec, s[6:7]666; GCN-NEXT:    s_mov_b32 s33, s4667; GCN-NEXT:    s_waitcnt vmcnt(0)668; GCN-NEXT:    s_setpc_b64 s[30:31]669  %local_val = alloca i32, align 128, addrspace(5)670  store volatile i32 %b, ptr addrspace(5) %local_val, align 128671 672  call void asm sideeffect "; clobber nonpreserved SGPRs and 64 CSRs",673    "~{s4},~{s5},~{s6},~{s7},~{s8},~{s9}674    ,~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},~{s16},~{s17},~{s18},~{s19}675    ,~{s20},~{s21},~{s22},~{s23},~{s24},~{s25},~{s26},~{s27},~{s28},~{s29}676    ,~{s40},~{s41},~{s42},~{s43},~{s44},~{s45},~{s46},~{s47},~{s48},~{s49}677    ,~{s50},~{s51},~{s52},~{s53},~{s54},~{s55},~{s56},~{s57},~{s58},~{s59}678    ,~{s60},~{s61},~{s62},~{s63},~{s64},~{s65},~{s66},~{s67},~{s68},~{s69}679    ,~{s70},~{s71},~{s72},~{s73},~{s74},~{s75},~{s76},~{s77},~{s78},~{s79}680    ,~{s80},~{s81},~{s82},~{s83},~{s84},~{s85},~{s86},~{s87},~{s88},~{s89}681    ,~{s90},~{s91},~{s92},~{s93},~{s94},~{s95},~{s96},~{s97},~{s98},~{s99}682    ,~{s100},~{s101},~{s102},~{s39},~{vcc}"() #0683 684  call void asm sideeffect "; clobber all VGPRs",685    "~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9}686    ,~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19}687    ,~{v20},~{v21},~{v22},~{v23},~{v24},~{v25},~{v26},~{v27},~{v28},~{v29}688    ,~{v30},~{v31},~{v32},~{v33},~{v34},~{v35},~{v36},~{v37},~{v38}"() #0689  ret void690}691 692attributes #0 = { noinline nounwind }693attributes #1 = { noinline nounwind "stackrealign" }694attributes #2 = { noinline nounwind alignstack=4 }695attributes #3 = { noinline nounwind "no-realign-stack" }696attributes #4 = { noinline nounwind "frame-pointer"="all"}697attributes #5 = { noinline nounwind "amdgpu-waves-per-eu"="6,6" }698