1375 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=amdgcn-amd-amdhsa < %s | FileCheck -check-prefix=GCN %s3; RUN: llc -mtriple=amdgcn-amd-amdhsa -global-isel < %s | FileCheck -check-prefix=GISEL %s4 5@gv.fptr0 = external hidden unnamed_addr addrspace(4) constant ptr, align 46@gv.fptr1 = external hidden unnamed_addr addrspace(4) constant ptr, align 47 8define amdgpu_kernel void @test_indirect_call_sgpr_ptr(i8) {9; GCN-LABEL: test_indirect_call_sgpr_ptr:10; GCN: ; %bb.0:11; GCN-NEXT: s_mov_b32 s32, 012; GCN-NEXT: s_mov_b32 flat_scratch_lo, s1313; GCN-NEXT: s_add_i32 s12, s12, s1714; GCN-NEXT: s_lshr_b32 flat_scratch_hi, s12, 815; GCN-NEXT: s_add_u32 s0, s0, s1716; GCN-NEXT: s_addc_u32 s1, s1, 017; GCN-NEXT: s_mov_b32 s13, s1518; GCN-NEXT: s_mov_b32 s12, s1419; GCN-NEXT: s_getpc_b64 s[14:15]20; GCN-NEXT: s_add_u32 s14, s14, gv.fptr0@rel32@lo+421; GCN-NEXT: s_addc_u32 s15, s15, gv.fptr0@rel32@hi+1222; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v223; GCN-NEXT: s_load_dwordx2 s[18:19], s[14:15], 0x024; GCN-NEXT: s_add_u32 s8, s8, 825; GCN-NEXT: s_addc_u32 s9, s9, 026; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v127; GCN-NEXT: v_or_b32_e32 v0, v0, v128; GCN-NEXT: v_or_b32_e32 v31, v0, v229; GCN-NEXT: s_mov_b32 s14, s1630; GCN-NEXT: s_waitcnt lgkmcnt(0)31; GCN-NEXT: s_swappc_b64 s[30:31], s[18:19]32; GCN-NEXT: s_endpgm33;34; GISEL-LABEL: test_indirect_call_sgpr_ptr:35; GISEL: ; %bb.0:36; GISEL-NEXT: s_mov_b32 s32, 037; GISEL-NEXT: s_mov_b32 flat_scratch_lo, s1338; GISEL-NEXT: s_add_i32 s12, s12, s1739; GISEL-NEXT: s_lshr_b32 flat_scratch_hi, s12, 840; GISEL-NEXT: s_add_u32 s0, s0, s1741; GISEL-NEXT: s_addc_u32 s1, s1, 042; GISEL-NEXT: s_mov_b32 s13, s1543; GISEL-NEXT: s_mov_b32 s12, s1444; GISEL-NEXT: s_getpc_b64 s[14:15]45; GISEL-NEXT: s_add_u32 s14, s14, gv.fptr0@rel32@lo+446; GISEL-NEXT: s_addc_u32 s15, s15, gv.fptr0@rel32@hi+1247; GISEL-NEXT: v_lshlrev_b32_e32 v1, 10, v148; GISEL-NEXT: s_load_dwordx2 s[18:19], s[14:15], 0x049; GISEL-NEXT: v_or_b32_e32 v0, v0, v150; GISEL-NEXT: s_add_u32 s8, s8, 851; GISEL-NEXT: s_addc_u32 s9, s9, 052; GISEL-NEXT: v_lshlrev_b32_e32 v1, 20, v253; GISEL-NEXT: v_or_b32_e32 v31, v0, v154; GISEL-NEXT: s_mov_b32 s14, s1655; GISEL-NEXT: s_waitcnt lgkmcnt(0)56; GISEL-NEXT: s_swappc_b64 s[30:31], s[18:19]57; GISEL-NEXT: s_endpgm58 %fptr = load ptr, ptr addrspace(4) @gv.fptr059 call void %fptr()60 ret void61}62 63define amdgpu_kernel void @test_indirect_call_sgpr_ptr_arg(i8) {64; GCN-LABEL: test_indirect_call_sgpr_ptr_arg:65; GCN: ; %bb.0:66; GCN-NEXT: s_mov_b32 s32, 067; GCN-NEXT: s_mov_b32 flat_scratch_lo, s1368; GCN-NEXT: s_add_i32 s12, s12, s1769; GCN-NEXT: s_lshr_b32 flat_scratch_hi, s12, 870; GCN-NEXT: s_add_u32 s0, s0, s1771; GCN-NEXT: s_addc_u32 s1, s1, 072; GCN-NEXT: s_mov_b32 s13, s1573; GCN-NEXT: s_mov_b32 s12, s1474; GCN-NEXT: s_getpc_b64 s[14:15]75; GCN-NEXT: s_add_u32 s14, s14, gv.fptr1@rel32@lo+476; GCN-NEXT: s_addc_u32 s15, s15, gv.fptr1@rel32@hi+1277; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v278; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v179; GCN-NEXT: s_load_dwordx2 s[18:19], s[14:15], 0x080; GCN-NEXT: s_add_u32 s8, s8, 881; GCN-NEXT: s_addc_u32 s9, s9, 082; GCN-NEXT: v_or_b32_e32 v0, v0, v183; GCN-NEXT: v_or_b32_e32 v31, v0, v284; GCN-NEXT: v_mov_b32_e32 v0, 0x7b85; GCN-NEXT: s_mov_b32 s14, s1686; GCN-NEXT: s_waitcnt lgkmcnt(0)87; GCN-NEXT: s_swappc_b64 s[30:31], s[18:19]88; GCN-NEXT: s_endpgm89;90; GISEL-LABEL: test_indirect_call_sgpr_ptr_arg:91; GISEL: ; %bb.0:92; GISEL-NEXT: s_mov_b32 s32, 093; GISEL-NEXT: s_mov_b32 flat_scratch_lo, s1394; GISEL-NEXT: s_add_i32 s12, s12, s1795; GISEL-NEXT: s_lshr_b32 flat_scratch_hi, s12, 896; GISEL-NEXT: s_add_u32 s0, s0, s1797; GISEL-NEXT: s_addc_u32 s1, s1, 098; GISEL-NEXT: s_mov_b32 s13, s1599; GISEL-NEXT: s_mov_b32 s12, s14100; GISEL-NEXT: s_getpc_b64 s[14:15]101; GISEL-NEXT: s_add_u32 s14, s14, gv.fptr1@rel32@lo+4102; GISEL-NEXT: s_addc_u32 s15, s15, gv.fptr1@rel32@hi+12103; GISEL-NEXT: v_lshlrev_b32_e32 v1, 10, v1104; GISEL-NEXT: v_lshlrev_b32_e32 v2, 20, v2105; GISEL-NEXT: s_load_dwordx2 s[18:19], s[14:15], 0x0106; GISEL-NEXT: v_or_b32_e32 v0, v0, v1107; GISEL-NEXT: s_add_u32 s8, s8, 8108; GISEL-NEXT: s_addc_u32 s9, s9, 0109; GISEL-NEXT: v_or_b32_e32 v31, v0, v2110; GISEL-NEXT: v_mov_b32_e32 v0, 0x7b111; GISEL-NEXT: s_mov_b32 s14, s16112; GISEL-NEXT: s_waitcnt lgkmcnt(0)113; GISEL-NEXT: s_swappc_b64 s[30:31], s[18:19]114; GISEL-NEXT: s_endpgm115 %fptr = load ptr, ptr addrspace(4) @gv.fptr1116 call void %fptr(i32 123)117 ret void118}119 120define void @test_indirect_call_vgpr_ptr(ptr %fptr) {121; GCN-LABEL: test_indirect_call_vgpr_ptr:122; GCN: ; %bb.0:123; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)124; GCN-NEXT: s_mov_b32 s16, s33125; GCN-NEXT: s_mov_b32 s33, s32126; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1127; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill128; GCN-NEXT: s_mov_b64 exec, s[18:19]129; GCN-NEXT: v_writelane_b32 v40, s16, 18130; GCN-NEXT: s_addk_i32 s32, 0x400131; GCN-NEXT: v_writelane_b32 v40, s30, 0132; GCN-NEXT: v_writelane_b32 v40, s31, 1133; GCN-NEXT: v_writelane_b32 v40, s34, 2134; GCN-NEXT: v_writelane_b32 v40, s35, 3135; GCN-NEXT: v_writelane_b32 v40, s36, 4136; GCN-NEXT: v_writelane_b32 v40, s37, 5137; GCN-NEXT: v_writelane_b32 v40, s38, 6138; GCN-NEXT: v_writelane_b32 v40, s39, 7139; GCN-NEXT: v_writelane_b32 v40, s48, 8140; GCN-NEXT: v_writelane_b32 v40, s49, 9141; GCN-NEXT: v_writelane_b32 v40, s50, 10142; GCN-NEXT: v_writelane_b32 v40, s51, 11143; GCN-NEXT: v_writelane_b32 v40, s52, 12144; GCN-NEXT: v_writelane_b32 v40, s53, 13145; GCN-NEXT: v_writelane_b32 v40, s54, 14146; GCN-NEXT: v_writelane_b32 v40, s55, 15147; GCN-NEXT: v_writelane_b32 v40, s64, 16148; GCN-NEXT: v_writelane_b32 v40, s65, 17149; GCN-NEXT: s_mov_b32 s50, s15150; GCN-NEXT: s_mov_b32 s51, s14151; GCN-NEXT: s_mov_b32 s52, s13152; GCN-NEXT: s_mov_b32 s53, s12153; GCN-NEXT: s_mov_b64 s[34:35], s[10:11]154; GCN-NEXT: s_mov_b64 s[36:37], s[8:9]155; GCN-NEXT: s_mov_b64 s[38:39], s[6:7]156; GCN-NEXT: s_mov_b64 s[48:49], s[4:5]157; GCN-NEXT: s_mov_b64 s[54:55], exec158; GCN-NEXT: .LBB2_1: ; =>This Inner Loop Header: Depth=1159; GCN-NEXT: v_readfirstlane_b32 s16, v0160; GCN-NEXT: v_readfirstlane_b32 s17, v1161; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]162; GCN-NEXT: s_and_saveexec_b64 s[64:65], vcc163; GCN-NEXT: s_mov_b64 s[4:5], s[48:49]164; GCN-NEXT: s_mov_b64 s[6:7], s[38:39]165; GCN-NEXT: s_mov_b64 s[8:9], s[36:37]166; GCN-NEXT: s_mov_b64 s[10:11], s[34:35]167; GCN-NEXT: s_mov_b32 s12, s53168; GCN-NEXT: s_mov_b32 s13, s52169; GCN-NEXT: s_mov_b32 s14, s51170; GCN-NEXT: s_mov_b32 s15, s50171; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]172; GCN-NEXT: ; implicit-def: $vgpr0_vgpr1173; GCN-NEXT: ; implicit-def: $vgpr31174; GCN-NEXT: s_xor_b64 exec, exec, s[64:65]175; GCN-NEXT: s_cbranch_execnz .LBB2_1176; GCN-NEXT: ; %bb.2:177; GCN-NEXT: s_mov_b64 exec, s[54:55]178; GCN-NEXT: v_readlane_b32 s65, v40, 17179; GCN-NEXT: v_readlane_b32 s64, v40, 16180; GCN-NEXT: v_readlane_b32 s55, v40, 15181; GCN-NEXT: v_readlane_b32 s54, v40, 14182; GCN-NEXT: v_readlane_b32 s53, v40, 13183; GCN-NEXT: v_readlane_b32 s52, v40, 12184; GCN-NEXT: v_readlane_b32 s51, v40, 11185; GCN-NEXT: v_readlane_b32 s50, v40, 10186; GCN-NEXT: v_readlane_b32 s49, v40, 9187; GCN-NEXT: v_readlane_b32 s48, v40, 8188; GCN-NEXT: v_readlane_b32 s39, v40, 7189; GCN-NEXT: v_readlane_b32 s38, v40, 6190; GCN-NEXT: v_readlane_b32 s37, v40, 5191; GCN-NEXT: v_readlane_b32 s36, v40, 4192; GCN-NEXT: v_readlane_b32 s35, v40, 3193; GCN-NEXT: v_readlane_b32 s34, v40, 2194; GCN-NEXT: v_readlane_b32 s31, v40, 1195; GCN-NEXT: v_readlane_b32 s30, v40, 0196; GCN-NEXT: s_mov_b32 s32, s33197; GCN-NEXT: v_readlane_b32 s4, v40, 18198; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1199; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload200; GCN-NEXT: s_mov_b64 exec, s[6:7]201; GCN-NEXT: s_mov_b32 s33, s4202; GCN-NEXT: s_waitcnt vmcnt(0)203; GCN-NEXT: s_setpc_b64 s[30:31]204;205; GISEL-LABEL: test_indirect_call_vgpr_ptr:206; GISEL: ; %bb.0:207; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)208; GISEL-NEXT: s_mov_b32 s16, s33209; GISEL-NEXT: s_mov_b32 s33, s32210; GISEL-NEXT: s_or_saveexec_b64 s[18:19], -1211; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill212; GISEL-NEXT: s_mov_b64 exec, s[18:19]213; GISEL-NEXT: v_writelane_b32 v40, s16, 18214; GISEL-NEXT: s_addk_i32 s32, 0x400215; GISEL-NEXT: v_writelane_b32 v40, s30, 0216; GISEL-NEXT: v_writelane_b32 v40, s31, 1217; GISEL-NEXT: v_writelane_b32 v40, s34, 2218; GISEL-NEXT: v_writelane_b32 v40, s35, 3219; GISEL-NEXT: v_writelane_b32 v40, s36, 4220; GISEL-NEXT: v_writelane_b32 v40, s37, 5221; GISEL-NEXT: v_writelane_b32 v40, s38, 6222; GISEL-NEXT: v_writelane_b32 v40, s39, 7223; GISEL-NEXT: v_writelane_b32 v40, s48, 8224; GISEL-NEXT: v_writelane_b32 v40, s49, 9225; GISEL-NEXT: v_writelane_b32 v40, s50, 10226; GISEL-NEXT: v_writelane_b32 v40, s51, 11227; GISEL-NEXT: v_writelane_b32 v40, s52, 12228; GISEL-NEXT: v_writelane_b32 v40, s53, 13229; GISEL-NEXT: v_writelane_b32 v40, s54, 14230; GISEL-NEXT: v_writelane_b32 v40, s55, 15231; GISEL-NEXT: v_writelane_b32 v40, s64, 16232; GISEL-NEXT: v_writelane_b32 v40, s65, 17233; GISEL-NEXT: s_mov_b32 s50, s15234; GISEL-NEXT: s_mov_b32 s51, s14235; GISEL-NEXT: s_mov_b32 s52, s13236; GISEL-NEXT: s_mov_b32 s53, s12237; GISEL-NEXT: s_mov_b64 s[34:35], s[10:11]238; GISEL-NEXT: s_mov_b64 s[36:37], s[8:9]239; GISEL-NEXT: s_mov_b64 s[38:39], s[6:7]240; GISEL-NEXT: s_mov_b64 s[48:49], s[4:5]241; GISEL-NEXT: s_mov_b64 s[54:55], exec242; GISEL-NEXT: .LBB2_1: ; =>This Inner Loop Header: Depth=1243; GISEL-NEXT: v_readfirstlane_b32 s16, v0244; GISEL-NEXT: v_readfirstlane_b32 s17, v1245; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]246; GISEL-NEXT: s_and_saveexec_b64 s[64:65], vcc247; GISEL-NEXT: s_mov_b64 s[4:5], s[48:49]248; GISEL-NEXT: s_mov_b64 s[6:7], s[38:39]249; GISEL-NEXT: s_mov_b64 s[8:9], s[36:37]250; GISEL-NEXT: s_mov_b64 s[10:11], s[34:35]251; GISEL-NEXT: s_mov_b32 s12, s53252; GISEL-NEXT: s_mov_b32 s13, s52253; GISEL-NEXT: s_mov_b32 s14, s51254; GISEL-NEXT: s_mov_b32 s15, s50255; GISEL-NEXT: s_swappc_b64 s[30:31], s[16:17]256; GISEL-NEXT: ; implicit-def: $vgpr0257; GISEL-NEXT: ; implicit-def: $vgpr31258; GISEL-NEXT: s_xor_b64 exec, exec, s[64:65]259; GISEL-NEXT: s_cbranch_execnz .LBB2_1260; GISEL-NEXT: ; %bb.2:261; GISEL-NEXT: s_mov_b64 exec, s[54:55]262; GISEL-NEXT: v_readlane_b32 s65, v40, 17263; GISEL-NEXT: v_readlane_b32 s64, v40, 16264; GISEL-NEXT: v_readlane_b32 s55, v40, 15265; GISEL-NEXT: v_readlane_b32 s54, v40, 14266; GISEL-NEXT: v_readlane_b32 s53, v40, 13267; GISEL-NEXT: v_readlane_b32 s52, v40, 12268; GISEL-NEXT: v_readlane_b32 s51, v40, 11269; GISEL-NEXT: v_readlane_b32 s50, v40, 10270; GISEL-NEXT: v_readlane_b32 s49, v40, 9271; GISEL-NEXT: v_readlane_b32 s48, v40, 8272; GISEL-NEXT: v_readlane_b32 s39, v40, 7273; GISEL-NEXT: v_readlane_b32 s38, v40, 6274; GISEL-NEXT: v_readlane_b32 s37, v40, 5275; GISEL-NEXT: v_readlane_b32 s36, v40, 4276; GISEL-NEXT: v_readlane_b32 s35, v40, 3277; GISEL-NEXT: v_readlane_b32 s34, v40, 2278; GISEL-NEXT: v_readlane_b32 s31, v40, 1279; GISEL-NEXT: v_readlane_b32 s30, v40, 0280; GISEL-NEXT: s_mov_b32 s32, s33281; GISEL-NEXT: v_readlane_b32 s4, v40, 18282; GISEL-NEXT: s_or_saveexec_b64 s[6:7], -1283; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload284; GISEL-NEXT: s_mov_b64 exec, s[6:7]285; GISEL-NEXT: s_mov_b32 s33, s4286; GISEL-NEXT: s_waitcnt vmcnt(0)287; GISEL-NEXT: s_setpc_b64 s[30:31]288 call void %fptr()289 ret void290}291 292define void @test_indirect_call_vgpr_ptr_arg(ptr %fptr) {293; GCN-LABEL: test_indirect_call_vgpr_ptr_arg:294; GCN: ; %bb.0:295; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)296; GCN-NEXT: s_mov_b32 s16, s33297; GCN-NEXT: s_mov_b32 s33, s32298; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1299; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill300; GCN-NEXT: s_mov_b64 exec, s[18:19]301; GCN-NEXT: v_writelane_b32 v40, s16, 18302; GCN-NEXT: s_addk_i32 s32, 0x400303; GCN-NEXT: v_writelane_b32 v40, s30, 0304; GCN-NEXT: v_writelane_b32 v40, s31, 1305; GCN-NEXT: v_writelane_b32 v40, s34, 2306; GCN-NEXT: v_writelane_b32 v40, s35, 3307; GCN-NEXT: v_writelane_b32 v40, s36, 4308; GCN-NEXT: v_writelane_b32 v40, s37, 5309; GCN-NEXT: v_writelane_b32 v40, s38, 6310; GCN-NEXT: v_writelane_b32 v40, s39, 7311; GCN-NEXT: v_writelane_b32 v40, s48, 8312; GCN-NEXT: v_writelane_b32 v40, s49, 9313; GCN-NEXT: v_writelane_b32 v40, s50, 10314; GCN-NEXT: v_writelane_b32 v40, s51, 11315; GCN-NEXT: v_writelane_b32 v40, s52, 12316; GCN-NEXT: v_writelane_b32 v40, s53, 13317; GCN-NEXT: v_writelane_b32 v40, s54, 14318; GCN-NEXT: v_writelane_b32 v40, s55, 15319; GCN-NEXT: v_writelane_b32 v40, s64, 16320; GCN-NEXT: v_writelane_b32 v40, s65, 17321; GCN-NEXT: s_mov_b32 s50, s15322; GCN-NEXT: s_mov_b32 s51, s14323; GCN-NEXT: s_mov_b32 s52, s13324; GCN-NEXT: s_mov_b32 s53, s12325; GCN-NEXT: s_mov_b64 s[34:35], s[10:11]326; GCN-NEXT: s_mov_b64 s[36:37], s[8:9]327; GCN-NEXT: s_mov_b64 s[38:39], s[6:7]328; GCN-NEXT: s_mov_b64 s[48:49], s[4:5]329; GCN-NEXT: s_mov_b64 s[54:55], exec330; GCN-NEXT: v_mov_b32_e32 v2, 0x7b331; GCN-NEXT: .LBB3_1: ; =>This Inner Loop Header: Depth=1332; GCN-NEXT: v_readfirstlane_b32 s16, v0333; GCN-NEXT: v_readfirstlane_b32 s17, v1334; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]335; GCN-NEXT: s_and_saveexec_b64 s[64:65], vcc336; GCN-NEXT: s_mov_b64 s[4:5], s[48:49]337; GCN-NEXT: s_mov_b64 s[6:7], s[38:39]338; GCN-NEXT: s_mov_b64 s[8:9], s[36:37]339; GCN-NEXT: s_mov_b64 s[10:11], s[34:35]340; GCN-NEXT: s_mov_b32 s12, s53341; GCN-NEXT: s_mov_b32 s13, s52342; GCN-NEXT: s_mov_b32 s14, s51343; GCN-NEXT: s_mov_b32 s15, s50344; GCN-NEXT: v_mov_b32_e32 v0, v2345; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]346; GCN-NEXT: ; implicit-def: $vgpr0_vgpr1347; GCN-NEXT: ; implicit-def: $vgpr31348; GCN-NEXT: ; implicit-def: $vgpr2349; GCN-NEXT: s_xor_b64 exec, exec, s[64:65]350; GCN-NEXT: s_cbranch_execnz .LBB3_1351; GCN-NEXT: ; %bb.2:352; GCN-NEXT: s_mov_b64 exec, s[54:55]353; GCN-NEXT: v_readlane_b32 s65, v40, 17354; GCN-NEXT: v_readlane_b32 s64, v40, 16355; GCN-NEXT: v_readlane_b32 s55, v40, 15356; GCN-NEXT: v_readlane_b32 s54, v40, 14357; GCN-NEXT: v_readlane_b32 s53, v40, 13358; GCN-NEXT: v_readlane_b32 s52, v40, 12359; GCN-NEXT: v_readlane_b32 s51, v40, 11360; GCN-NEXT: v_readlane_b32 s50, v40, 10361; GCN-NEXT: v_readlane_b32 s49, v40, 9362; GCN-NEXT: v_readlane_b32 s48, v40, 8363; GCN-NEXT: v_readlane_b32 s39, v40, 7364; GCN-NEXT: v_readlane_b32 s38, v40, 6365; GCN-NEXT: v_readlane_b32 s37, v40, 5366; GCN-NEXT: v_readlane_b32 s36, v40, 4367; GCN-NEXT: v_readlane_b32 s35, v40, 3368; GCN-NEXT: v_readlane_b32 s34, v40, 2369; GCN-NEXT: v_readlane_b32 s31, v40, 1370; GCN-NEXT: v_readlane_b32 s30, v40, 0371; GCN-NEXT: s_mov_b32 s32, s33372; GCN-NEXT: v_readlane_b32 s4, v40, 18373; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1374; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload375; GCN-NEXT: s_mov_b64 exec, s[6:7]376; GCN-NEXT: s_mov_b32 s33, s4377; GCN-NEXT: s_waitcnt vmcnt(0)378; GCN-NEXT: s_setpc_b64 s[30:31]379;380; GISEL-LABEL: test_indirect_call_vgpr_ptr_arg:381; GISEL: ; %bb.0:382; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)383; GISEL-NEXT: s_mov_b32 s16, s33384; GISEL-NEXT: s_mov_b32 s33, s32385; GISEL-NEXT: s_or_saveexec_b64 s[18:19], -1386; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill387; GISEL-NEXT: s_mov_b64 exec, s[18:19]388; GISEL-NEXT: v_writelane_b32 v40, s16, 18389; GISEL-NEXT: s_addk_i32 s32, 0x400390; GISEL-NEXT: v_writelane_b32 v40, s30, 0391; GISEL-NEXT: v_writelane_b32 v40, s31, 1392; GISEL-NEXT: v_writelane_b32 v40, s34, 2393; GISEL-NEXT: v_writelane_b32 v40, s35, 3394; GISEL-NEXT: v_writelane_b32 v40, s36, 4395; GISEL-NEXT: v_writelane_b32 v40, s37, 5396; GISEL-NEXT: v_writelane_b32 v40, s38, 6397; GISEL-NEXT: v_writelane_b32 v40, s39, 7398; GISEL-NEXT: v_writelane_b32 v40, s48, 8399; GISEL-NEXT: v_writelane_b32 v40, s49, 9400; GISEL-NEXT: v_writelane_b32 v40, s50, 10401; GISEL-NEXT: v_writelane_b32 v40, s51, 11402; GISEL-NEXT: v_writelane_b32 v40, s52, 12403; GISEL-NEXT: v_writelane_b32 v40, s53, 13404; GISEL-NEXT: v_writelane_b32 v40, s54, 14405; GISEL-NEXT: v_writelane_b32 v40, s55, 15406; GISEL-NEXT: v_writelane_b32 v40, s64, 16407; GISEL-NEXT: v_writelane_b32 v40, s65, 17408; GISEL-NEXT: s_mov_b32 s50, s15409; GISEL-NEXT: s_mov_b32 s51, s14410; GISEL-NEXT: s_mov_b32 s52, s13411; GISEL-NEXT: s_mov_b32 s53, s12412; GISEL-NEXT: s_mov_b64 s[34:35], s[10:11]413; GISEL-NEXT: s_mov_b64 s[36:37], s[8:9]414; GISEL-NEXT: s_mov_b64 s[38:39], s[6:7]415; GISEL-NEXT: s_mov_b64 s[48:49], s[4:5]416; GISEL-NEXT: s_mov_b64 s[54:55], exec417; GISEL-NEXT: .LBB3_1: ; =>This Inner Loop Header: Depth=1418; GISEL-NEXT: v_readfirstlane_b32 s16, v0419; GISEL-NEXT: v_readfirstlane_b32 s17, v1420; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]421; GISEL-NEXT: s_and_saveexec_b64 s[64:65], vcc422; GISEL-NEXT: v_mov_b32_e32 v0, 0x7b423; GISEL-NEXT: s_mov_b64 s[4:5], s[48:49]424; GISEL-NEXT: s_mov_b64 s[6:7], s[38:39]425; GISEL-NEXT: s_mov_b64 s[8:9], s[36:37]426; GISEL-NEXT: s_mov_b64 s[10:11], s[34:35]427; GISEL-NEXT: s_mov_b32 s12, s53428; GISEL-NEXT: s_mov_b32 s13, s52429; GISEL-NEXT: s_mov_b32 s14, s51430; GISEL-NEXT: s_mov_b32 s15, s50431; GISEL-NEXT: s_swappc_b64 s[30:31], s[16:17]432; GISEL-NEXT: ; implicit-def: $vgpr0433; GISEL-NEXT: ; implicit-def: $vgpr31434; GISEL-NEXT: s_xor_b64 exec, exec, s[64:65]435; GISEL-NEXT: s_cbranch_execnz .LBB3_1436; GISEL-NEXT: ; %bb.2:437; GISEL-NEXT: s_mov_b64 exec, s[54:55]438; GISEL-NEXT: v_readlane_b32 s65, v40, 17439; GISEL-NEXT: v_readlane_b32 s64, v40, 16440; GISEL-NEXT: v_readlane_b32 s55, v40, 15441; GISEL-NEXT: v_readlane_b32 s54, v40, 14442; GISEL-NEXT: v_readlane_b32 s53, v40, 13443; GISEL-NEXT: v_readlane_b32 s52, v40, 12444; GISEL-NEXT: v_readlane_b32 s51, v40, 11445; GISEL-NEXT: v_readlane_b32 s50, v40, 10446; GISEL-NEXT: v_readlane_b32 s49, v40, 9447; GISEL-NEXT: v_readlane_b32 s48, v40, 8448; GISEL-NEXT: v_readlane_b32 s39, v40, 7449; GISEL-NEXT: v_readlane_b32 s38, v40, 6450; GISEL-NEXT: v_readlane_b32 s37, v40, 5451; GISEL-NEXT: v_readlane_b32 s36, v40, 4452; GISEL-NEXT: v_readlane_b32 s35, v40, 3453; GISEL-NEXT: v_readlane_b32 s34, v40, 2454; GISEL-NEXT: v_readlane_b32 s31, v40, 1455; GISEL-NEXT: v_readlane_b32 s30, v40, 0456; GISEL-NEXT: s_mov_b32 s32, s33457; GISEL-NEXT: v_readlane_b32 s4, v40, 18458; GISEL-NEXT: s_or_saveexec_b64 s[6:7], -1459; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload460; GISEL-NEXT: s_mov_b64 exec, s[6:7]461; GISEL-NEXT: s_mov_b32 s33, s4462; GISEL-NEXT: s_waitcnt vmcnt(0)463; GISEL-NEXT: s_setpc_b64 s[30:31]464 call void %fptr(i32 123)465 ret void466}467 468define i32 @test_indirect_call_vgpr_ptr_ret(ptr %fptr) {469; GCN-LABEL: test_indirect_call_vgpr_ptr_ret:470; GCN: ; %bb.0:471; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)472; GCN-NEXT: s_mov_b32 s16, s33473; GCN-NEXT: s_mov_b32 s33, s32474; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1475; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill476; GCN-NEXT: s_mov_b64 exec, s[18:19]477; GCN-NEXT: v_writelane_b32 v40, s16, 18478; GCN-NEXT: s_addk_i32 s32, 0x400479; GCN-NEXT: v_writelane_b32 v40, s30, 0480; GCN-NEXT: v_writelane_b32 v40, s31, 1481; GCN-NEXT: v_writelane_b32 v40, s34, 2482; GCN-NEXT: v_writelane_b32 v40, s35, 3483; GCN-NEXT: v_writelane_b32 v40, s36, 4484; GCN-NEXT: v_writelane_b32 v40, s37, 5485; GCN-NEXT: v_writelane_b32 v40, s38, 6486; GCN-NEXT: v_writelane_b32 v40, s39, 7487; GCN-NEXT: v_writelane_b32 v40, s48, 8488; GCN-NEXT: v_writelane_b32 v40, s49, 9489; GCN-NEXT: v_writelane_b32 v40, s50, 10490; GCN-NEXT: v_writelane_b32 v40, s51, 11491; GCN-NEXT: v_writelane_b32 v40, s52, 12492; GCN-NEXT: v_writelane_b32 v40, s53, 13493; GCN-NEXT: v_writelane_b32 v40, s54, 14494; GCN-NEXT: v_writelane_b32 v40, s55, 15495; GCN-NEXT: v_writelane_b32 v40, s64, 16496; GCN-NEXT: v_writelane_b32 v40, s65, 17497; GCN-NEXT: s_mov_b32 s50, s15498; GCN-NEXT: s_mov_b32 s51, s14499; GCN-NEXT: s_mov_b32 s52, s13500; GCN-NEXT: s_mov_b32 s53, s12501; GCN-NEXT: s_mov_b64 s[34:35], s[10:11]502; GCN-NEXT: s_mov_b64 s[36:37], s[8:9]503; GCN-NEXT: s_mov_b64 s[38:39], s[6:7]504; GCN-NEXT: s_mov_b64 s[48:49], s[4:5]505; GCN-NEXT: s_mov_b64 s[54:55], exec506; GCN-NEXT: .LBB4_1: ; =>This Inner Loop Header: Depth=1507; GCN-NEXT: v_readfirstlane_b32 s16, v0508; GCN-NEXT: v_readfirstlane_b32 s17, v1509; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]510; GCN-NEXT: s_and_saveexec_b64 s[64:65], vcc511; GCN-NEXT: s_mov_b64 s[4:5], s[48:49]512; GCN-NEXT: s_mov_b64 s[6:7], s[38:39]513; GCN-NEXT: s_mov_b64 s[8:9], s[36:37]514; GCN-NEXT: s_mov_b64 s[10:11], s[34:35]515; GCN-NEXT: s_mov_b32 s12, s53516; GCN-NEXT: s_mov_b32 s13, s52517; GCN-NEXT: s_mov_b32 s14, s51518; GCN-NEXT: s_mov_b32 s15, s50519; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]520; GCN-NEXT: v_mov_b32_e32 v2, v0521; GCN-NEXT: ; implicit-def: $vgpr0_vgpr1522; GCN-NEXT: ; implicit-def: $vgpr31523; GCN-NEXT: s_xor_b64 exec, exec, s[64:65]524; GCN-NEXT: s_cbranch_execnz .LBB4_1525; GCN-NEXT: ; %bb.2:526; GCN-NEXT: s_mov_b64 exec, s[54:55]527; GCN-NEXT: v_add_i32_e32 v0, vcc, 1, v2528; GCN-NEXT: v_readlane_b32 s65, v40, 17529; GCN-NEXT: v_readlane_b32 s64, v40, 16530; GCN-NEXT: v_readlane_b32 s55, v40, 15531; GCN-NEXT: v_readlane_b32 s54, v40, 14532; GCN-NEXT: v_readlane_b32 s53, v40, 13533; GCN-NEXT: v_readlane_b32 s52, v40, 12534; GCN-NEXT: v_readlane_b32 s51, v40, 11535; GCN-NEXT: v_readlane_b32 s50, v40, 10536; GCN-NEXT: v_readlane_b32 s49, v40, 9537; GCN-NEXT: v_readlane_b32 s48, v40, 8538; GCN-NEXT: v_readlane_b32 s39, v40, 7539; GCN-NEXT: v_readlane_b32 s38, v40, 6540; GCN-NEXT: v_readlane_b32 s37, v40, 5541; GCN-NEXT: v_readlane_b32 s36, v40, 4542; GCN-NEXT: v_readlane_b32 s35, v40, 3543; GCN-NEXT: v_readlane_b32 s34, v40, 2544; GCN-NEXT: v_readlane_b32 s31, v40, 1545; GCN-NEXT: v_readlane_b32 s30, v40, 0546; GCN-NEXT: s_mov_b32 s32, s33547; GCN-NEXT: v_readlane_b32 s4, v40, 18548; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1549; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload550; GCN-NEXT: s_mov_b64 exec, s[6:7]551; GCN-NEXT: s_mov_b32 s33, s4552; GCN-NEXT: s_waitcnt vmcnt(0)553; GCN-NEXT: s_setpc_b64 s[30:31]554;555; GISEL-LABEL: test_indirect_call_vgpr_ptr_ret:556; GISEL: ; %bb.0:557; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)558; GISEL-NEXT: s_mov_b32 s16, s33559; GISEL-NEXT: s_mov_b32 s33, s32560; GISEL-NEXT: s_or_saveexec_b64 s[18:19], -1561; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill562; GISEL-NEXT: s_mov_b64 exec, s[18:19]563; GISEL-NEXT: v_writelane_b32 v40, s16, 18564; GISEL-NEXT: s_addk_i32 s32, 0x400565; GISEL-NEXT: v_writelane_b32 v40, s30, 0566; GISEL-NEXT: v_writelane_b32 v40, s31, 1567; GISEL-NEXT: v_writelane_b32 v40, s34, 2568; GISEL-NEXT: v_writelane_b32 v40, s35, 3569; GISEL-NEXT: v_writelane_b32 v40, s36, 4570; GISEL-NEXT: v_writelane_b32 v40, s37, 5571; GISEL-NEXT: v_writelane_b32 v40, s38, 6572; GISEL-NEXT: v_writelane_b32 v40, s39, 7573; GISEL-NEXT: v_writelane_b32 v40, s48, 8574; GISEL-NEXT: v_writelane_b32 v40, s49, 9575; GISEL-NEXT: v_writelane_b32 v40, s50, 10576; GISEL-NEXT: v_writelane_b32 v40, s51, 11577; GISEL-NEXT: v_writelane_b32 v40, s52, 12578; GISEL-NEXT: v_writelane_b32 v40, s53, 13579; GISEL-NEXT: v_writelane_b32 v40, s54, 14580; GISEL-NEXT: v_writelane_b32 v40, s55, 15581; GISEL-NEXT: v_writelane_b32 v40, s64, 16582; GISEL-NEXT: v_writelane_b32 v40, s65, 17583; GISEL-NEXT: s_mov_b32 s50, s15584; GISEL-NEXT: s_mov_b32 s51, s14585; GISEL-NEXT: s_mov_b32 s52, s13586; GISEL-NEXT: s_mov_b32 s53, s12587; GISEL-NEXT: s_mov_b64 s[34:35], s[10:11]588; GISEL-NEXT: s_mov_b64 s[36:37], s[8:9]589; GISEL-NEXT: s_mov_b64 s[38:39], s[6:7]590; GISEL-NEXT: s_mov_b64 s[48:49], s[4:5]591; GISEL-NEXT: s_mov_b64 s[54:55], exec592; GISEL-NEXT: .LBB4_1: ; =>This Inner Loop Header: Depth=1593; GISEL-NEXT: v_readfirstlane_b32 s16, v0594; GISEL-NEXT: v_readfirstlane_b32 s17, v1595; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]596; GISEL-NEXT: s_and_saveexec_b64 s[64:65], vcc597; GISEL-NEXT: s_mov_b64 s[4:5], s[48:49]598; GISEL-NEXT: s_mov_b64 s[6:7], s[38:39]599; GISEL-NEXT: s_mov_b64 s[8:9], s[36:37]600; GISEL-NEXT: s_mov_b64 s[10:11], s[34:35]601; GISEL-NEXT: s_mov_b32 s12, s53602; GISEL-NEXT: s_mov_b32 s13, s52603; GISEL-NEXT: s_mov_b32 s14, s51604; GISEL-NEXT: s_mov_b32 s15, s50605; GISEL-NEXT: s_swappc_b64 s[30:31], s[16:17]606; GISEL-NEXT: v_mov_b32_e32 v1, v0607; GISEL-NEXT: ; implicit-def: $vgpr0608; GISEL-NEXT: ; implicit-def: $vgpr31609; GISEL-NEXT: s_xor_b64 exec, exec, s[64:65]610; GISEL-NEXT: s_cbranch_execnz .LBB4_1611; GISEL-NEXT: ; %bb.2:612; GISEL-NEXT: s_mov_b64 exec, s[54:55]613; GISEL-NEXT: v_add_i32_e32 v0, vcc, 1, v1614; GISEL-NEXT: v_readlane_b32 s65, v40, 17615; GISEL-NEXT: v_readlane_b32 s64, v40, 16616; GISEL-NEXT: v_readlane_b32 s55, v40, 15617; GISEL-NEXT: v_readlane_b32 s54, v40, 14618; GISEL-NEXT: v_readlane_b32 s53, v40, 13619; GISEL-NEXT: v_readlane_b32 s52, v40, 12620; GISEL-NEXT: v_readlane_b32 s51, v40, 11621; GISEL-NEXT: v_readlane_b32 s50, v40, 10622; GISEL-NEXT: v_readlane_b32 s49, v40, 9623; GISEL-NEXT: v_readlane_b32 s48, v40, 8624; GISEL-NEXT: v_readlane_b32 s39, v40, 7625; GISEL-NEXT: v_readlane_b32 s38, v40, 6626; GISEL-NEXT: v_readlane_b32 s37, v40, 5627; GISEL-NEXT: v_readlane_b32 s36, v40, 4628; GISEL-NEXT: v_readlane_b32 s35, v40, 3629; GISEL-NEXT: v_readlane_b32 s34, v40, 2630; GISEL-NEXT: v_readlane_b32 s31, v40, 1631; GISEL-NEXT: v_readlane_b32 s30, v40, 0632; GISEL-NEXT: s_mov_b32 s32, s33633; GISEL-NEXT: v_readlane_b32 s4, v40, 18634; GISEL-NEXT: s_or_saveexec_b64 s[6:7], -1635; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload636; GISEL-NEXT: s_mov_b64 exec, s[6:7]637; GISEL-NEXT: s_mov_b32 s33, s4638; GISEL-NEXT: s_waitcnt vmcnt(0)639; GISEL-NEXT: s_setpc_b64 s[30:31]640 %a = call i32 %fptr()641 %b = add i32 %a, 1642 ret i32 %b643}644 645define void @test_indirect_call_vgpr_ptr_in_branch(ptr %fptr, i1 %cond) {646; GCN-LABEL: test_indirect_call_vgpr_ptr_in_branch:647; GCN: ; %bb.0: ; %bb0648; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)649; GCN-NEXT: s_mov_b32 s16, s33650; GCN-NEXT: s_mov_b32 s33, s32651; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1652; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill653; GCN-NEXT: s_mov_b64 exec, s[18:19]654; GCN-NEXT: v_writelane_b32 v40, s16, 20655; GCN-NEXT: s_addk_i32 s32, 0x400656; GCN-NEXT: v_writelane_b32 v40, s30, 0657; GCN-NEXT: v_writelane_b32 v40, s31, 1658; GCN-NEXT: v_writelane_b32 v40, s34, 2659; GCN-NEXT: v_writelane_b32 v40, s35, 3660; GCN-NEXT: v_writelane_b32 v40, s36, 4661; GCN-NEXT: v_writelane_b32 v40, s37, 5662; GCN-NEXT: v_writelane_b32 v40, s38, 6663; GCN-NEXT: v_writelane_b32 v40, s39, 7664; GCN-NEXT: v_writelane_b32 v40, s48, 8665; GCN-NEXT: v_writelane_b32 v40, s49, 9666; GCN-NEXT: v_writelane_b32 v40, s50, 10667; GCN-NEXT: v_writelane_b32 v40, s51, 11668; GCN-NEXT: v_writelane_b32 v40, s52, 12669; GCN-NEXT: v_writelane_b32 v40, s53, 13670; GCN-NEXT: v_writelane_b32 v40, s54, 14671; GCN-NEXT: v_writelane_b32 v40, s55, 15672; GCN-NEXT: v_writelane_b32 v40, s64, 16673; GCN-NEXT: v_writelane_b32 v40, s65, 17674; GCN-NEXT: v_writelane_b32 v40, s66, 18675; GCN-NEXT: v_writelane_b32 v40, s67, 19676; GCN-NEXT: s_mov_b32 s50, s15677; GCN-NEXT: s_mov_b32 s51, s14678; GCN-NEXT: s_mov_b32 s52, s13679; GCN-NEXT: s_mov_b32 s53, s12680; GCN-NEXT: s_mov_b64 s[34:35], s[10:11]681; GCN-NEXT: s_mov_b64 s[36:37], s[8:9]682; GCN-NEXT: s_mov_b64 s[38:39], s[6:7]683; GCN-NEXT: s_mov_b64 s[48:49], s[4:5]684; GCN-NEXT: v_and_b32_e32 v2, 1, v2685; GCN-NEXT: v_cmp_eq_u32_e32 vcc, 1, v2686; GCN-NEXT: s_and_saveexec_b64 s[54:55], vcc687; GCN-NEXT: s_cbranch_execz .LBB5_4688; GCN-NEXT: ; %bb.1: ; %bb1689; GCN-NEXT: s_mov_b64 s[64:65], exec690; GCN-NEXT: .LBB5_2: ; =>This Inner Loop Header: Depth=1691; GCN-NEXT: v_readfirstlane_b32 s16, v0692; GCN-NEXT: v_readfirstlane_b32 s17, v1693; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]694; GCN-NEXT: s_and_saveexec_b64 s[66:67], vcc695; GCN-NEXT: s_mov_b64 s[4:5], s[48:49]696; GCN-NEXT: s_mov_b64 s[6:7], s[38:39]697; GCN-NEXT: s_mov_b64 s[8:9], s[36:37]698; GCN-NEXT: s_mov_b64 s[10:11], s[34:35]699; GCN-NEXT: s_mov_b32 s12, s53700; GCN-NEXT: s_mov_b32 s13, s52701; GCN-NEXT: s_mov_b32 s14, s51702; GCN-NEXT: s_mov_b32 s15, s50703; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]704; GCN-NEXT: ; implicit-def: $vgpr0_vgpr1705; GCN-NEXT: ; implicit-def: $vgpr31706; GCN-NEXT: s_xor_b64 exec, exec, s[66:67]707; GCN-NEXT: s_cbranch_execnz .LBB5_2708; GCN-NEXT: ; %bb.3:709; GCN-NEXT: s_mov_b64 exec, s[64:65]710; GCN-NEXT: .LBB5_4: ; %bb2711; GCN-NEXT: s_or_b64 exec, exec, s[54:55]712; GCN-NEXT: v_readlane_b32 s67, v40, 19713; GCN-NEXT: v_readlane_b32 s66, v40, 18714; GCN-NEXT: v_readlane_b32 s65, v40, 17715; GCN-NEXT: v_readlane_b32 s64, v40, 16716; GCN-NEXT: v_readlane_b32 s55, v40, 15717; GCN-NEXT: v_readlane_b32 s54, v40, 14718; GCN-NEXT: v_readlane_b32 s53, v40, 13719; GCN-NEXT: v_readlane_b32 s52, v40, 12720; GCN-NEXT: v_readlane_b32 s51, v40, 11721; GCN-NEXT: v_readlane_b32 s50, v40, 10722; GCN-NEXT: v_readlane_b32 s49, v40, 9723; GCN-NEXT: v_readlane_b32 s48, v40, 8724; GCN-NEXT: v_readlane_b32 s39, v40, 7725; GCN-NEXT: v_readlane_b32 s38, v40, 6726; GCN-NEXT: v_readlane_b32 s37, v40, 5727; GCN-NEXT: v_readlane_b32 s36, v40, 4728; GCN-NEXT: v_readlane_b32 s35, v40, 3729; GCN-NEXT: v_readlane_b32 s34, v40, 2730; GCN-NEXT: v_readlane_b32 s31, v40, 1731; GCN-NEXT: v_readlane_b32 s30, v40, 0732; GCN-NEXT: s_mov_b32 s32, s33733; GCN-NEXT: v_readlane_b32 s4, v40, 20734; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1735; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload736; GCN-NEXT: s_mov_b64 exec, s[6:7]737; GCN-NEXT: s_mov_b32 s33, s4738; GCN-NEXT: s_waitcnt vmcnt(0)739; GCN-NEXT: s_setpc_b64 s[30:31]740;741; GISEL-LABEL: test_indirect_call_vgpr_ptr_in_branch:742; GISEL: ; %bb.0: ; %bb0743; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)744; GISEL-NEXT: s_mov_b32 s16, s33745; GISEL-NEXT: s_mov_b32 s33, s32746; GISEL-NEXT: s_or_saveexec_b64 s[18:19], -1747; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill748; GISEL-NEXT: s_mov_b64 exec, s[18:19]749; GISEL-NEXT: v_writelane_b32 v40, s16, 20750; GISEL-NEXT: s_addk_i32 s32, 0x400751; GISEL-NEXT: v_writelane_b32 v40, s30, 0752; GISEL-NEXT: v_writelane_b32 v40, s31, 1753; GISEL-NEXT: v_writelane_b32 v40, s34, 2754; GISEL-NEXT: v_writelane_b32 v40, s35, 3755; GISEL-NEXT: v_writelane_b32 v40, s36, 4756; GISEL-NEXT: v_writelane_b32 v40, s37, 5757; GISEL-NEXT: v_writelane_b32 v40, s38, 6758; GISEL-NEXT: v_writelane_b32 v40, s39, 7759; GISEL-NEXT: v_writelane_b32 v40, s48, 8760; GISEL-NEXT: v_writelane_b32 v40, s49, 9761; GISEL-NEXT: v_writelane_b32 v40, s50, 10762; GISEL-NEXT: v_writelane_b32 v40, s51, 11763; GISEL-NEXT: v_writelane_b32 v40, s52, 12764; GISEL-NEXT: v_writelane_b32 v40, s53, 13765; GISEL-NEXT: v_writelane_b32 v40, s54, 14766; GISEL-NEXT: v_writelane_b32 v40, s55, 15767; GISEL-NEXT: v_writelane_b32 v40, s64, 16768; GISEL-NEXT: v_writelane_b32 v40, s65, 17769; GISEL-NEXT: v_writelane_b32 v40, s66, 18770; GISEL-NEXT: v_writelane_b32 v40, s67, 19771; GISEL-NEXT: s_mov_b32 s50, s15772; GISEL-NEXT: s_mov_b32 s51, s14773; GISEL-NEXT: s_mov_b32 s52, s13774; GISEL-NEXT: s_mov_b32 s53, s12775; GISEL-NEXT: s_mov_b64 s[34:35], s[10:11]776; GISEL-NEXT: s_mov_b64 s[36:37], s[8:9]777; GISEL-NEXT: s_mov_b64 s[38:39], s[6:7]778; GISEL-NEXT: s_mov_b64 s[48:49], s[4:5]779; GISEL-NEXT: v_and_b32_e32 v2, 1, v2780; GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2781; GISEL-NEXT: s_and_saveexec_b64 s[54:55], vcc782; GISEL-NEXT: s_cbranch_execz .LBB5_4783; GISEL-NEXT: ; %bb.1: ; %bb1784; GISEL-NEXT: s_mov_b64 s[64:65], exec785; GISEL-NEXT: .LBB5_2: ; =>This Inner Loop Header: Depth=1786; GISEL-NEXT: v_readfirstlane_b32 s16, v0787; GISEL-NEXT: v_readfirstlane_b32 s17, v1788; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]789; GISEL-NEXT: s_and_saveexec_b64 s[66:67], vcc790; GISEL-NEXT: s_mov_b64 s[4:5], s[48:49]791; GISEL-NEXT: s_mov_b64 s[6:7], s[38:39]792; GISEL-NEXT: s_mov_b64 s[8:9], s[36:37]793; GISEL-NEXT: s_mov_b64 s[10:11], s[34:35]794; GISEL-NEXT: s_mov_b32 s12, s53795; GISEL-NEXT: s_mov_b32 s13, s52796; GISEL-NEXT: s_mov_b32 s14, s51797; GISEL-NEXT: s_mov_b32 s15, s50798; GISEL-NEXT: s_swappc_b64 s[30:31], s[16:17]799; GISEL-NEXT: ; implicit-def: $vgpr0800; GISEL-NEXT: ; implicit-def: $vgpr31801; GISEL-NEXT: s_xor_b64 exec, exec, s[66:67]802; GISEL-NEXT: s_cbranch_execnz .LBB5_2803; GISEL-NEXT: ; %bb.3:804; GISEL-NEXT: s_mov_b64 exec, s[64:65]805; GISEL-NEXT: .LBB5_4: ; %bb2806; GISEL-NEXT: s_or_b64 exec, exec, s[54:55]807; GISEL-NEXT: v_readlane_b32 s67, v40, 19808; GISEL-NEXT: v_readlane_b32 s66, v40, 18809; GISEL-NEXT: v_readlane_b32 s65, v40, 17810; GISEL-NEXT: v_readlane_b32 s64, v40, 16811; GISEL-NEXT: v_readlane_b32 s55, v40, 15812; GISEL-NEXT: v_readlane_b32 s54, v40, 14813; GISEL-NEXT: v_readlane_b32 s53, v40, 13814; GISEL-NEXT: v_readlane_b32 s52, v40, 12815; GISEL-NEXT: v_readlane_b32 s51, v40, 11816; GISEL-NEXT: v_readlane_b32 s50, v40, 10817; GISEL-NEXT: v_readlane_b32 s49, v40, 9818; GISEL-NEXT: v_readlane_b32 s48, v40, 8819; GISEL-NEXT: v_readlane_b32 s39, v40, 7820; GISEL-NEXT: v_readlane_b32 s38, v40, 6821; GISEL-NEXT: v_readlane_b32 s37, v40, 5822; GISEL-NEXT: v_readlane_b32 s36, v40, 4823; GISEL-NEXT: v_readlane_b32 s35, v40, 3824; GISEL-NEXT: v_readlane_b32 s34, v40, 2825; GISEL-NEXT: v_readlane_b32 s31, v40, 1826; GISEL-NEXT: v_readlane_b32 s30, v40, 0827; GISEL-NEXT: s_mov_b32 s32, s33828; GISEL-NEXT: v_readlane_b32 s4, v40, 20829; GISEL-NEXT: s_or_saveexec_b64 s[6:7], -1830; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload831; GISEL-NEXT: s_mov_b64 exec, s[6:7]832; GISEL-NEXT: s_mov_b32 s33, s4833; GISEL-NEXT: s_waitcnt vmcnt(0)834; GISEL-NEXT: s_setpc_b64 s[30:31]835bb0:836 br i1 %cond, label %bb1, label %bb2837 838bb1:839 call void %fptr()840 br label %bb2841 842bb2:843 ret void844}845 846define void @test_indirect_call_vgpr_ptr_inreg_arg(ptr %fptr) {847; GCN-LABEL: test_indirect_call_vgpr_ptr_inreg_arg:848; GCN: ; %bb.0:849; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)850; GCN-NEXT: s_mov_b32 s5, s33851; GCN-NEXT: s_mov_b32 s33, s32852; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1853; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill854; GCN-NEXT: s_mov_b64 exec, s[6:7]855; GCN-NEXT: s_addk_i32 s32, 0x400856; GCN-NEXT: v_writelane_b32 v40, s30, 0857; GCN-NEXT: v_writelane_b32 v40, s31, 1858; GCN-NEXT: v_writelane_b32 v40, s34, 2859; GCN-NEXT: v_writelane_b32 v40, s35, 3860; GCN-NEXT: v_writelane_b32 v40, s36, 4861; GCN-NEXT: v_writelane_b32 v40, s37, 5862; GCN-NEXT: v_writelane_b32 v40, s38, 6863; GCN-NEXT: v_writelane_b32 v40, s39, 7864; GCN-NEXT: v_writelane_b32 v40, s48, 8865; GCN-NEXT: v_writelane_b32 v40, s49, 9866; GCN-NEXT: v_writelane_b32 v40, s50, 10867; GCN-NEXT: v_writelane_b32 v40, s51, 11868; GCN-NEXT: v_writelane_b32 v40, s52, 12869; GCN-NEXT: v_writelane_b32 v40, s53, 13870; GCN-NEXT: v_writelane_b32 v40, s54, 14871; GCN-NEXT: v_writelane_b32 v40, s55, 15872; GCN-NEXT: s_mov_b64 s[6:7], exec873; GCN-NEXT: .LBB6_1: ; =>This Inner Loop Header: Depth=1874; GCN-NEXT: v_readfirstlane_b32 s8, v0875; GCN-NEXT: v_readfirstlane_b32 s9, v1876; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[8:9], v[0:1]877; GCN-NEXT: s_and_saveexec_b64 s[10:11], vcc878; GCN-NEXT: s_movk_i32 s4, 0x7b879; GCN-NEXT: s_swappc_b64 s[30:31], s[8:9]880; GCN-NEXT: ; implicit-def: $vgpr0_vgpr1881; GCN-NEXT: s_xor_b64 exec, exec, s[10:11]882; GCN-NEXT: s_cbranch_execnz .LBB6_1883; GCN-NEXT: ; %bb.2:884; GCN-NEXT: s_mov_b64 exec, s[6:7]885; GCN-NEXT: v_readlane_b32 s55, v40, 15886; GCN-NEXT: v_readlane_b32 s54, v40, 14887; GCN-NEXT: v_readlane_b32 s53, v40, 13888; GCN-NEXT: v_readlane_b32 s52, v40, 12889; GCN-NEXT: v_readlane_b32 s51, v40, 11890; GCN-NEXT: v_readlane_b32 s50, v40, 10891; GCN-NEXT: v_readlane_b32 s49, v40, 9892; GCN-NEXT: v_readlane_b32 s48, v40, 8893; GCN-NEXT: v_readlane_b32 s39, v40, 7894; GCN-NEXT: v_readlane_b32 s38, v40, 6895; GCN-NEXT: v_readlane_b32 s37, v40, 5896; GCN-NEXT: v_readlane_b32 s36, v40, 4897; GCN-NEXT: v_readlane_b32 s35, v40, 3898; GCN-NEXT: v_readlane_b32 s34, v40, 2899; GCN-NEXT: v_readlane_b32 s31, v40, 1900; GCN-NEXT: v_readlane_b32 s30, v40, 0901; GCN-NEXT: s_mov_b32 s32, s33902; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1903; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload904; GCN-NEXT: s_mov_b64 exec, s[6:7]905; GCN-NEXT: s_mov_b32 s33, s5906; GCN-NEXT: s_waitcnt vmcnt(0)907; GCN-NEXT: s_setpc_b64 s[30:31]908;909; GISEL-LABEL: test_indirect_call_vgpr_ptr_inreg_arg:910; GISEL: ; %bb.0:911; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)912; GISEL-NEXT: s_mov_b32 s5, s33913; GISEL-NEXT: s_mov_b32 s33, s32914; GISEL-NEXT: s_or_saveexec_b64 s[6:7], -1915; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill916; GISEL-NEXT: s_mov_b64 exec, s[6:7]917; GISEL-NEXT: s_addk_i32 s32, 0x400918; GISEL-NEXT: v_writelane_b32 v40, s30, 0919; GISEL-NEXT: v_writelane_b32 v40, s31, 1920; GISEL-NEXT: v_writelane_b32 v40, s34, 2921; GISEL-NEXT: v_writelane_b32 v40, s35, 3922; GISEL-NEXT: v_writelane_b32 v40, s36, 4923; GISEL-NEXT: v_writelane_b32 v40, s37, 5924; GISEL-NEXT: v_writelane_b32 v40, s38, 6925; GISEL-NEXT: v_writelane_b32 v40, s39, 7926; GISEL-NEXT: v_writelane_b32 v40, s48, 8927; GISEL-NEXT: v_writelane_b32 v40, s49, 9928; GISEL-NEXT: v_writelane_b32 v40, s50, 10929; GISEL-NEXT: v_writelane_b32 v40, s51, 11930; GISEL-NEXT: v_writelane_b32 v40, s52, 12931; GISEL-NEXT: v_writelane_b32 v40, s53, 13932; GISEL-NEXT: v_writelane_b32 v40, s54, 14933; GISEL-NEXT: v_writelane_b32 v40, s55, 15934; GISEL-NEXT: s_mov_b64 s[6:7], exec935; GISEL-NEXT: .LBB6_1: ; =>This Inner Loop Header: Depth=1936; GISEL-NEXT: v_readfirstlane_b32 s8, v0937; GISEL-NEXT: v_readfirstlane_b32 s9, v1938; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[8:9], v[0:1]939; GISEL-NEXT: s_and_saveexec_b64 s[10:11], vcc940; GISEL-NEXT: s_movk_i32 s4, 0x7b941; GISEL-NEXT: s_swappc_b64 s[30:31], s[8:9]942; GISEL-NEXT: ; implicit-def: $vgpr0943; GISEL-NEXT: s_xor_b64 exec, exec, s[10:11]944; GISEL-NEXT: s_cbranch_execnz .LBB6_1945; GISEL-NEXT: ; %bb.2:946; GISEL-NEXT: s_mov_b64 exec, s[6:7]947; GISEL-NEXT: v_readlane_b32 s55, v40, 15948; GISEL-NEXT: v_readlane_b32 s54, v40, 14949; GISEL-NEXT: v_readlane_b32 s53, v40, 13950; GISEL-NEXT: v_readlane_b32 s52, v40, 12951; GISEL-NEXT: v_readlane_b32 s51, v40, 11952; GISEL-NEXT: v_readlane_b32 s50, v40, 10953; GISEL-NEXT: v_readlane_b32 s49, v40, 9954; GISEL-NEXT: v_readlane_b32 s48, v40, 8955; GISEL-NEXT: v_readlane_b32 s39, v40, 7956; GISEL-NEXT: v_readlane_b32 s38, v40, 6957; GISEL-NEXT: v_readlane_b32 s37, v40, 5958; GISEL-NEXT: v_readlane_b32 s36, v40, 4959; GISEL-NEXT: v_readlane_b32 s35, v40, 3960; GISEL-NEXT: v_readlane_b32 s34, v40, 2961; GISEL-NEXT: v_readlane_b32 s31, v40, 1962; GISEL-NEXT: v_readlane_b32 s30, v40, 0963; GISEL-NEXT: s_mov_b32 s32, s33964; GISEL-NEXT: s_or_saveexec_b64 s[6:7], -1965; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload966; GISEL-NEXT: s_mov_b64 exec, s[6:7]967; GISEL-NEXT: s_mov_b32 s33, s5968; GISEL-NEXT: s_waitcnt vmcnt(0)969; GISEL-NEXT: s_setpc_b64 s[30:31]970 call amdgpu_gfx void %fptr(i32 inreg 123)971 ret void972}973 974define i32 @test_indirect_call_vgpr_ptr_arg_and_reuse(i32 %i, ptr %fptr) {975; GCN-LABEL: test_indirect_call_vgpr_ptr_arg_and_reuse:976; GCN: ; %bb.0:977; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)978; GCN-NEXT: s_mov_b32 s10, s33979; GCN-NEXT: s_mov_b32 s33, s32980; GCN-NEXT: s_or_saveexec_b64 s[4:5], -1981; GCN-NEXT: buffer_store_dword v41, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill982; GCN-NEXT: s_mov_b64 exec, s[4:5]983; GCN-NEXT: s_addk_i32 s32, 0x400984; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill985; GCN-NEXT: v_writelane_b32 v41, s30, 0986; GCN-NEXT: v_writelane_b32 v41, s31, 1987; GCN-NEXT: v_writelane_b32 v41, s34, 2988; GCN-NEXT: v_writelane_b32 v41, s35, 3989; GCN-NEXT: v_writelane_b32 v41, s36, 4990; GCN-NEXT: v_writelane_b32 v41, s37, 5991; GCN-NEXT: v_writelane_b32 v41, s38, 6992; GCN-NEXT: v_writelane_b32 v41, s39, 7993; GCN-NEXT: v_writelane_b32 v41, s48, 8994; GCN-NEXT: v_writelane_b32 v41, s49, 9995; GCN-NEXT: v_writelane_b32 v41, s50, 10996; GCN-NEXT: v_writelane_b32 v41, s51, 11997; GCN-NEXT: v_writelane_b32 v41, s52, 12998; GCN-NEXT: v_writelane_b32 v41, s53, 13999; GCN-NEXT: v_writelane_b32 v41, s54, 141000; GCN-NEXT: v_writelane_b32 v41, s55, 151001; GCN-NEXT: v_mov_b32_e32 v40, v01002; GCN-NEXT: s_mov_b64 s[4:5], exec1003; GCN-NEXT: .LBB7_1: ; =>This Inner Loop Header: Depth=11004; GCN-NEXT: v_readfirstlane_b32 s6, v11005; GCN-NEXT: v_readfirstlane_b32 s7, v21006; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[6:7], v[1:2]1007; GCN-NEXT: s_and_saveexec_b64 s[8:9], vcc1008; GCN-NEXT: v_mov_b32_e32 v0, v401009; GCN-NEXT: s_swappc_b64 s[30:31], s[6:7]1010; GCN-NEXT: ; implicit-def: $vgpr1_vgpr21011; GCN-NEXT: s_xor_b64 exec, exec, s[8:9]1012; GCN-NEXT: s_cbranch_execnz .LBB7_11013; GCN-NEXT: ; %bb.2:1014; GCN-NEXT: s_mov_b64 exec, s[4:5]1015; GCN-NEXT: v_mov_b32_e32 v0, v401016; GCN-NEXT: v_readlane_b32 s55, v41, 151017; GCN-NEXT: v_readlane_b32 s54, v41, 141018; GCN-NEXT: v_readlane_b32 s53, v41, 131019; GCN-NEXT: v_readlane_b32 s52, v41, 121020; GCN-NEXT: v_readlane_b32 s51, v41, 111021; GCN-NEXT: v_readlane_b32 s50, v41, 101022; GCN-NEXT: v_readlane_b32 s49, v41, 91023; GCN-NEXT: v_readlane_b32 s48, v41, 81024; GCN-NEXT: v_readlane_b32 s39, v41, 71025; GCN-NEXT: v_readlane_b32 s38, v41, 61026; GCN-NEXT: v_readlane_b32 s37, v41, 51027; GCN-NEXT: v_readlane_b32 s36, v41, 41028; GCN-NEXT: v_readlane_b32 s35, v41, 31029; GCN-NEXT: v_readlane_b32 s34, v41, 21030; GCN-NEXT: v_readlane_b32 s31, v41, 11031; GCN-NEXT: v_readlane_b32 s30, v41, 01032; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1033; GCN-NEXT: s_mov_b32 s32, s331034; GCN-NEXT: s_or_saveexec_b64 s[4:5], -11035; GCN-NEXT: buffer_load_dword v41, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload1036; GCN-NEXT: s_mov_b64 exec, s[4:5]1037; GCN-NEXT: s_mov_b32 s33, s101038; GCN-NEXT: s_waitcnt vmcnt(0)1039; GCN-NEXT: s_setpc_b64 s[30:31]1040;1041; GISEL-LABEL: test_indirect_call_vgpr_ptr_arg_and_reuse:1042; GISEL: ; %bb.0:1043; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1044; GISEL-NEXT: s_mov_b32 s10, s331045; GISEL-NEXT: s_mov_b32 s33, s321046; GISEL-NEXT: s_or_saveexec_b64 s[4:5], -11047; GISEL-NEXT: buffer_store_dword v41, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill1048; GISEL-NEXT: s_mov_b64 exec, s[4:5]1049; GISEL-NEXT: s_addk_i32 s32, 0x4001050; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill1051; GISEL-NEXT: v_writelane_b32 v41, s30, 01052; GISEL-NEXT: v_writelane_b32 v41, s31, 11053; GISEL-NEXT: v_writelane_b32 v41, s34, 21054; GISEL-NEXT: v_writelane_b32 v41, s35, 31055; GISEL-NEXT: v_writelane_b32 v41, s36, 41056; GISEL-NEXT: v_writelane_b32 v41, s37, 51057; GISEL-NEXT: v_writelane_b32 v41, s38, 61058; GISEL-NEXT: v_writelane_b32 v41, s39, 71059; GISEL-NEXT: v_writelane_b32 v41, s48, 81060; GISEL-NEXT: v_writelane_b32 v41, s49, 91061; GISEL-NEXT: v_writelane_b32 v41, s50, 101062; GISEL-NEXT: v_writelane_b32 v41, s51, 111063; GISEL-NEXT: v_writelane_b32 v41, s52, 121064; GISEL-NEXT: v_writelane_b32 v41, s53, 131065; GISEL-NEXT: v_writelane_b32 v41, s54, 141066; GISEL-NEXT: v_writelane_b32 v41, s55, 151067; GISEL-NEXT: v_mov_b32_e32 v40, v01068; GISEL-NEXT: s_mov_b64 s[4:5], exec1069; GISEL-NEXT: .LBB7_1: ; =>This Inner Loop Header: Depth=11070; GISEL-NEXT: v_readfirstlane_b32 s6, v11071; GISEL-NEXT: v_readfirstlane_b32 s7, v21072; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[6:7], v[1:2]1073; GISEL-NEXT: s_and_saveexec_b64 s[8:9], vcc1074; GISEL-NEXT: v_mov_b32_e32 v0, v401075; GISEL-NEXT: s_swappc_b64 s[30:31], s[6:7]1076; GISEL-NEXT: ; implicit-def: $vgpr11077; GISEL-NEXT: s_xor_b64 exec, exec, s[8:9]1078; GISEL-NEXT: s_cbranch_execnz .LBB7_11079; GISEL-NEXT: ; %bb.2:1080; GISEL-NEXT: s_mov_b64 exec, s[4:5]1081; GISEL-NEXT: v_mov_b32_e32 v0, v401082; GISEL-NEXT: v_readlane_b32 s55, v41, 151083; GISEL-NEXT: v_readlane_b32 s54, v41, 141084; GISEL-NEXT: v_readlane_b32 s53, v41, 131085; GISEL-NEXT: v_readlane_b32 s52, v41, 121086; GISEL-NEXT: v_readlane_b32 s51, v41, 111087; GISEL-NEXT: v_readlane_b32 s50, v41, 101088; GISEL-NEXT: v_readlane_b32 s49, v41, 91089; GISEL-NEXT: v_readlane_b32 s48, v41, 81090; GISEL-NEXT: v_readlane_b32 s39, v41, 71091; GISEL-NEXT: v_readlane_b32 s38, v41, 61092; GISEL-NEXT: v_readlane_b32 s37, v41, 51093; GISEL-NEXT: v_readlane_b32 s36, v41, 41094; GISEL-NEXT: v_readlane_b32 s35, v41, 31095; GISEL-NEXT: v_readlane_b32 s34, v41, 21096; GISEL-NEXT: v_readlane_b32 s31, v41, 11097; GISEL-NEXT: v_readlane_b32 s30, v41, 01098; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1099; GISEL-NEXT: s_mov_b32 s32, s331100; GISEL-NEXT: s_or_saveexec_b64 s[4:5], -11101; GISEL-NEXT: buffer_load_dword v41, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload1102; GISEL-NEXT: s_mov_b64 exec, s[4:5]1103; GISEL-NEXT: s_mov_b32 s33, s101104; GISEL-NEXT: s_waitcnt vmcnt(0)1105; GISEL-NEXT: s_setpc_b64 s[30:31]1106 call amdgpu_gfx void %fptr(i32 %i)1107 ret i32 %i1108}1109 1110; Use a variable inside a waterfall loop and use the return variable after the loop.1111; TODO The argument and return variable could be in the same physical register, but the register1112; allocator is not able to do that because the return value clashes with the liverange of an1113; IMPLICIT_DEF of the argument.1114define i32 @test_indirect_call_vgpr_ptr_arg_and_return(i32 %i, ptr %fptr) {1115; GCN-LABEL: test_indirect_call_vgpr_ptr_arg_and_return:1116; GCN: ; %bb.0:1117; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1118; GCN-NEXT: s_mov_b32 s10, s331119; GCN-NEXT: s_mov_b32 s33, s321120; GCN-NEXT: s_or_saveexec_b64 s[4:5], -11121; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill1122; GCN-NEXT: s_mov_b64 exec, s[4:5]1123; GCN-NEXT: s_addk_i32 s32, 0x4001124; GCN-NEXT: v_writelane_b32 v40, s30, 01125; GCN-NEXT: v_writelane_b32 v40, s31, 11126; GCN-NEXT: v_writelane_b32 v40, s34, 21127; GCN-NEXT: v_writelane_b32 v40, s35, 31128; GCN-NEXT: v_writelane_b32 v40, s36, 41129; GCN-NEXT: v_writelane_b32 v40, s37, 51130; GCN-NEXT: v_writelane_b32 v40, s38, 61131; GCN-NEXT: v_writelane_b32 v40, s39, 71132; GCN-NEXT: v_writelane_b32 v40, s48, 81133; GCN-NEXT: v_writelane_b32 v40, s49, 91134; GCN-NEXT: v_writelane_b32 v40, s50, 101135; GCN-NEXT: v_writelane_b32 v40, s51, 111136; GCN-NEXT: v_writelane_b32 v40, s52, 121137; GCN-NEXT: v_writelane_b32 v40, s53, 131138; GCN-NEXT: v_writelane_b32 v40, s54, 141139; GCN-NEXT: v_writelane_b32 v40, s55, 151140; GCN-NEXT: s_mov_b64 s[4:5], exec1141; GCN-NEXT: .LBB8_1: ; =>This Inner Loop Header: Depth=11142; GCN-NEXT: v_readfirstlane_b32 s8, v11143; GCN-NEXT: v_readfirstlane_b32 s9, v21144; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[8:9], v[1:2]1145; GCN-NEXT: s_and_saveexec_b64 s[6:7], vcc1146; GCN-NEXT: s_swappc_b64 s[30:31], s[8:9]1147; GCN-NEXT: v_mov_b32_e32 v3, v01148; GCN-NEXT: ; implicit-def: $vgpr1_vgpr21149; GCN-NEXT: ; implicit-def: $vgpr01150; GCN-NEXT: s_xor_b64 exec, exec, s[6:7]1151; GCN-NEXT: s_cbranch_execnz .LBB8_11152; GCN-NEXT: ; %bb.2:1153; GCN-NEXT: s_mov_b64 exec, s[4:5]1154; GCN-NEXT: v_mov_b32_e32 v0, v31155; GCN-NEXT: v_readlane_b32 s55, v40, 151156; GCN-NEXT: v_readlane_b32 s54, v40, 141157; GCN-NEXT: v_readlane_b32 s53, v40, 131158; GCN-NEXT: v_readlane_b32 s52, v40, 121159; GCN-NEXT: v_readlane_b32 s51, v40, 111160; GCN-NEXT: v_readlane_b32 s50, v40, 101161; GCN-NEXT: v_readlane_b32 s49, v40, 91162; GCN-NEXT: v_readlane_b32 s48, v40, 81163; GCN-NEXT: v_readlane_b32 s39, v40, 71164; GCN-NEXT: v_readlane_b32 s38, v40, 61165; GCN-NEXT: v_readlane_b32 s37, v40, 51166; GCN-NEXT: v_readlane_b32 s36, v40, 41167; GCN-NEXT: v_readlane_b32 s35, v40, 31168; GCN-NEXT: v_readlane_b32 s34, v40, 21169; GCN-NEXT: v_readlane_b32 s31, v40, 11170; GCN-NEXT: v_readlane_b32 s30, v40, 01171; GCN-NEXT: s_mov_b32 s32, s331172; GCN-NEXT: s_or_saveexec_b64 s[4:5], -11173; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1174; GCN-NEXT: s_mov_b64 exec, s[4:5]1175; GCN-NEXT: s_mov_b32 s33, s101176; GCN-NEXT: s_waitcnt vmcnt(0)1177; GCN-NEXT: s_setpc_b64 s[30:31]1178;1179; GISEL-LABEL: test_indirect_call_vgpr_ptr_arg_and_return:1180; GISEL: ; %bb.0:1181; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1182; GISEL-NEXT: s_mov_b32 s10, s331183; GISEL-NEXT: s_mov_b32 s33, s321184; GISEL-NEXT: s_or_saveexec_b64 s[4:5], -11185; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill1186; GISEL-NEXT: s_mov_b64 exec, s[4:5]1187; GISEL-NEXT: s_addk_i32 s32, 0x4001188; GISEL-NEXT: v_writelane_b32 v40, s30, 01189; GISEL-NEXT: v_writelane_b32 v40, s31, 11190; GISEL-NEXT: v_writelane_b32 v40, s34, 21191; GISEL-NEXT: v_writelane_b32 v40, s35, 31192; GISEL-NEXT: v_writelane_b32 v40, s36, 41193; GISEL-NEXT: v_writelane_b32 v40, s37, 51194; GISEL-NEXT: v_writelane_b32 v40, s38, 61195; GISEL-NEXT: v_writelane_b32 v40, s39, 71196; GISEL-NEXT: v_writelane_b32 v40, s48, 81197; GISEL-NEXT: v_writelane_b32 v40, s49, 91198; GISEL-NEXT: v_writelane_b32 v40, s50, 101199; GISEL-NEXT: v_writelane_b32 v40, s51, 111200; GISEL-NEXT: v_writelane_b32 v40, s52, 121201; GISEL-NEXT: v_writelane_b32 v40, s53, 131202; GISEL-NEXT: v_writelane_b32 v40, s54, 141203; GISEL-NEXT: v_writelane_b32 v40, s55, 151204; GISEL-NEXT: s_mov_b64 s[4:5], exec1205; GISEL-NEXT: .LBB8_1: ; =>This Inner Loop Header: Depth=11206; GISEL-NEXT: v_readfirstlane_b32 s8, v11207; GISEL-NEXT: v_readfirstlane_b32 s9, v21208; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[8:9], v[1:2]1209; GISEL-NEXT: s_and_saveexec_b64 s[6:7], vcc1210; GISEL-NEXT: s_swappc_b64 s[30:31], s[8:9]1211; GISEL-NEXT: v_mov_b32_e32 v2, v01212; GISEL-NEXT: ; implicit-def: $vgpr11213; GISEL-NEXT: ; implicit-def: $vgpr01214; GISEL-NEXT: s_xor_b64 exec, exec, s[6:7]1215; GISEL-NEXT: s_cbranch_execnz .LBB8_11216; GISEL-NEXT: ; %bb.2:1217; GISEL-NEXT: s_mov_b64 exec, s[4:5]1218; GISEL-NEXT: v_mov_b32_e32 v0, v21219; GISEL-NEXT: v_readlane_b32 s55, v40, 151220; GISEL-NEXT: v_readlane_b32 s54, v40, 141221; GISEL-NEXT: v_readlane_b32 s53, v40, 131222; GISEL-NEXT: v_readlane_b32 s52, v40, 121223; GISEL-NEXT: v_readlane_b32 s51, v40, 111224; GISEL-NEXT: v_readlane_b32 s50, v40, 101225; GISEL-NEXT: v_readlane_b32 s49, v40, 91226; GISEL-NEXT: v_readlane_b32 s48, v40, 81227; GISEL-NEXT: v_readlane_b32 s39, v40, 71228; GISEL-NEXT: v_readlane_b32 s38, v40, 61229; GISEL-NEXT: v_readlane_b32 s37, v40, 51230; GISEL-NEXT: v_readlane_b32 s36, v40, 41231; GISEL-NEXT: v_readlane_b32 s35, v40, 31232; GISEL-NEXT: v_readlane_b32 s34, v40, 21233; GISEL-NEXT: v_readlane_b32 s31, v40, 11234; GISEL-NEXT: v_readlane_b32 s30, v40, 01235; GISEL-NEXT: s_mov_b32 s32, s331236; GISEL-NEXT: s_or_saveexec_b64 s[4:5], -11237; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1238; GISEL-NEXT: s_mov_b64 exec, s[4:5]1239; GISEL-NEXT: s_mov_b32 s33, s101240; GISEL-NEXT: s_waitcnt vmcnt(0)1241; GISEL-NEXT: s_setpc_b64 s[30:31]1242 %ret = call amdgpu_gfx i32 %fptr(i32 %i)1243 ret i32 %ret1244}1245 1246; Calling a vgpr can never be a tail call.1247define void @test_indirect_tail_call_vgpr_ptr(ptr %fptr) {1248; GCN-LABEL: test_indirect_tail_call_vgpr_ptr:1249; GCN: ; %bb.0:1250; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1251; GCN-NEXT: s_mov_b32 s10, s331252; GCN-NEXT: s_mov_b32 s33, s321253; GCN-NEXT: s_or_saveexec_b64 s[4:5], -11254; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill1255; GCN-NEXT: s_mov_b64 exec, s[4:5]1256; GCN-NEXT: s_addk_i32 s32, 0x4001257; GCN-NEXT: v_writelane_b32 v40, s30, 01258; GCN-NEXT: v_writelane_b32 v40, s31, 11259; GCN-NEXT: v_writelane_b32 v40, s34, 21260; GCN-NEXT: v_writelane_b32 v40, s35, 31261; GCN-NEXT: v_writelane_b32 v40, s36, 41262; GCN-NEXT: v_writelane_b32 v40, s37, 51263; GCN-NEXT: v_writelane_b32 v40, s38, 61264; GCN-NEXT: v_writelane_b32 v40, s39, 71265; GCN-NEXT: v_writelane_b32 v40, s48, 81266; GCN-NEXT: v_writelane_b32 v40, s49, 91267; GCN-NEXT: v_writelane_b32 v40, s50, 101268; GCN-NEXT: v_writelane_b32 v40, s51, 111269; GCN-NEXT: v_writelane_b32 v40, s52, 121270; GCN-NEXT: v_writelane_b32 v40, s53, 131271; GCN-NEXT: v_writelane_b32 v40, s54, 141272; GCN-NEXT: v_writelane_b32 v40, s55, 151273; GCN-NEXT: s_mov_b64 s[4:5], exec1274; GCN-NEXT: .LBB9_1: ; =>This Inner Loop Header: Depth=11275; GCN-NEXT: v_readfirstlane_b32 s6, v01276; GCN-NEXT: v_readfirstlane_b32 s7, v11277; GCN-NEXT: v_cmp_eq_u64_e32 vcc, s[6:7], v[0:1]1278; GCN-NEXT: s_and_saveexec_b64 s[8:9], vcc1279; GCN-NEXT: s_swappc_b64 s[30:31], s[6:7]1280; GCN-NEXT: ; implicit-def: $vgpr0_vgpr11281; GCN-NEXT: s_xor_b64 exec, exec, s[8:9]1282; GCN-NEXT: s_cbranch_execnz .LBB9_11283; GCN-NEXT: ; %bb.2:1284; GCN-NEXT: s_mov_b64 exec, s[4:5]1285; GCN-NEXT: v_readlane_b32 s55, v40, 151286; GCN-NEXT: v_readlane_b32 s54, v40, 141287; GCN-NEXT: v_readlane_b32 s53, v40, 131288; GCN-NEXT: v_readlane_b32 s52, v40, 121289; GCN-NEXT: v_readlane_b32 s51, v40, 111290; GCN-NEXT: v_readlane_b32 s50, v40, 101291; GCN-NEXT: v_readlane_b32 s49, v40, 91292; GCN-NEXT: v_readlane_b32 s48, v40, 81293; GCN-NEXT: v_readlane_b32 s39, v40, 71294; GCN-NEXT: v_readlane_b32 s38, v40, 61295; GCN-NEXT: v_readlane_b32 s37, v40, 51296; GCN-NEXT: v_readlane_b32 s36, v40, 41297; GCN-NEXT: v_readlane_b32 s35, v40, 31298; GCN-NEXT: v_readlane_b32 s34, v40, 21299; GCN-NEXT: v_readlane_b32 s31, v40, 11300; GCN-NEXT: v_readlane_b32 s30, v40, 01301; GCN-NEXT: s_mov_b32 s32, s331302; GCN-NEXT: s_or_saveexec_b64 s[4:5], -11303; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1304; GCN-NEXT: s_mov_b64 exec, s[4:5]1305; GCN-NEXT: s_mov_b32 s33, s101306; GCN-NEXT: s_waitcnt vmcnt(0)1307; GCN-NEXT: s_setpc_b64 s[30:31]1308;1309; GISEL-LABEL: test_indirect_tail_call_vgpr_ptr:1310; GISEL: ; %bb.0:1311; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1312; GISEL-NEXT: s_mov_b32 s10, s331313; GISEL-NEXT: s_mov_b32 s33, s321314; GISEL-NEXT: s_or_saveexec_b64 s[4:5], -11315; GISEL-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill1316; GISEL-NEXT: s_mov_b64 exec, s[4:5]1317; GISEL-NEXT: s_addk_i32 s32, 0x4001318; GISEL-NEXT: v_writelane_b32 v40, s30, 01319; GISEL-NEXT: v_writelane_b32 v40, s31, 11320; GISEL-NEXT: v_writelane_b32 v40, s34, 21321; GISEL-NEXT: v_writelane_b32 v40, s35, 31322; GISEL-NEXT: v_writelane_b32 v40, s36, 41323; GISEL-NEXT: v_writelane_b32 v40, s37, 51324; GISEL-NEXT: v_writelane_b32 v40, s38, 61325; GISEL-NEXT: v_writelane_b32 v40, s39, 71326; GISEL-NEXT: v_writelane_b32 v40, s48, 81327; GISEL-NEXT: v_writelane_b32 v40, s49, 91328; GISEL-NEXT: v_writelane_b32 v40, s50, 101329; GISEL-NEXT: v_writelane_b32 v40, s51, 111330; GISEL-NEXT: v_writelane_b32 v40, s52, 121331; GISEL-NEXT: v_writelane_b32 v40, s53, 131332; GISEL-NEXT: v_writelane_b32 v40, s54, 141333; GISEL-NEXT: v_writelane_b32 v40, s55, 151334; GISEL-NEXT: s_mov_b64 s[4:5], exec1335; GISEL-NEXT: .LBB9_1: ; =>This Inner Loop Header: Depth=11336; GISEL-NEXT: v_readfirstlane_b32 s6, v01337; GISEL-NEXT: v_readfirstlane_b32 s7, v11338; GISEL-NEXT: v_cmp_eq_u64_e32 vcc, s[6:7], v[0:1]1339; GISEL-NEXT: s_and_saveexec_b64 s[8:9], vcc1340; GISEL-NEXT: s_swappc_b64 s[30:31], s[6:7]1341; GISEL-NEXT: ; implicit-def: $vgpr01342; GISEL-NEXT: s_xor_b64 exec, exec, s[8:9]1343; GISEL-NEXT: s_cbranch_execnz .LBB9_11344; GISEL-NEXT: ; %bb.2:1345; GISEL-NEXT: s_mov_b64 exec, s[4:5]1346; GISEL-NEXT: v_readlane_b32 s55, v40, 151347; GISEL-NEXT: v_readlane_b32 s54, v40, 141348; GISEL-NEXT: v_readlane_b32 s53, v40, 131349; GISEL-NEXT: v_readlane_b32 s52, v40, 121350; GISEL-NEXT: v_readlane_b32 s51, v40, 111351; GISEL-NEXT: v_readlane_b32 s50, v40, 101352; GISEL-NEXT: v_readlane_b32 s49, v40, 91353; GISEL-NEXT: v_readlane_b32 s48, v40, 81354; GISEL-NEXT: v_readlane_b32 s39, v40, 71355; GISEL-NEXT: v_readlane_b32 s38, v40, 61356; GISEL-NEXT: v_readlane_b32 s37, v40, 51357; GISEL-NEXT: v_readlane_b32 s36, v40, 41358; GISEL-NEXT: v_readlane_b32 s35, v40, 31359; GISEL-NEXT: v_readlane_b32 s34, v40, 21360; GISEL-NEXT: v_readlane_b32 s31, v40, 11361; GISEL-NEXT: v_readlane_b32 s30, v40, 01362; GISEL-NEXT: s_mov_b32 s32, s331363; GISEL-NEXT: s_or_saveexec_b64 s[4:5], -11364; GISEL-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1365; GISEL-NEXT: s_mov_b64 exec, s[4:5]1366; GISEL-NEXT: s_mov_b32 s33, s101367; GISEL-NEXT: s_waitcnt vmcnt(0)1368; GISEL-NEXT: s_setpc_b64 s[30:31]1369 tail call amdgpu_gfx void %fptr()1370 ret void1371}1372 1373!llvm.module.flags = !{!0}1374!0 = !{i32 1, !"amdhsa_code_object_version", i32 400}1375