289 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefix=GCN %s3 4; SelectionDAG builder was using the IR value kind to decide how to5; split the types for copyToRegs/copyFromRegs in all contexts. This6; was incorrect if the ABI-like value such as a call was used outside7; of the block. The value in that case is not used directly, but8; through another set of copies to potentially different register9; types in the parent block.10 11; This would then end up producing inconsistent pairs of copies with12; the wrong sizes when the vector type result from the call was split13; into multiple pieces, but expected to be a single register in the14; cross-block copy.15;16; This isn't exactly ideal for AMDGPU, since in reality the17; intermediate vector register type is undesirable anyway, but it18; requires more work to be able to split all vector copies in all19; contexts.20;21; This was only an issue if the value was used directly in another22; block. If there was an intermediate operation or a phi it was fine,23; since that didn't look like an ABI copy.24 25 26define float @call_split_type_used_outside_block_v2f32() #0 {27; GCN-LABEL: call_split_type_used_outside_block_v2f32:28; GCN: ; %bb.0: ; %bb029; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)30; GCN-NEXT: s_mov_b32 s16, s3331; GCN-NEXT: s_mov_b32 s33, s3232; GCN-NEXT: s_or_saveexec_b64 s[18:19], -133; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill34; GCN-NEXT: s_mov_b64 exec, s[18:19]35; GCN-NEXT: v_writelane_b32 v40, s16, 236; GCN-NEXT: s_addk_i32 s32, 0x40037; GCN-NEXT: v_writelane_b32 v40, s30, 038; GCN-NEXT: s_getpc_b64 s[16:17]39; GCN-NEXT: s_add_u32 s16, s16, func_v2f32@rel32@lo+440; GCN-NEXT: s_addc_u32 s17, s17, func_v2f32@rel32@hi+1241; GCN-NEXT: v_writelane_b32 v40, s31, 142; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]43; GCN-NEXT: v_readlane_b32 s31, v40, 144; GCN-NEXT: v_readlane_b32 s30, v40, 045; GCN-NEXT: s_mov_b32 s32, s3346; GCN-NEXT: v_readlane_b32 s4, v40, 247; GCN-NEXT: s_or_saveexec_b64 s[6:7], -148; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload49; GCN-NEXT: s_mov_b64 exec, s[6:7]50; GCN-NEXT: s_mov_b32 s33, s451; GCN-NEXT: s_waitcnt vmcnt(0)52; GCN-NEXT: s_setpc_b64 s[30:31]53bb0:54 %split.ret.type = call <2 x float> @func_v2f32()55 br label %bb156 57bb1:58 %extract = extractelement <2 x float> %split.ret.type, i32 059 ret float %extract60}61 62define float @call_split_type_used_outside_block_v3f32() #0 {63; GCN-LABEL: call_split_type_used_outside_block_v3f32:64; GCN: ; %bb.0: ; %bb065; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)66; GCN-NEXT: s_mov_b32 s16, s3367; GCN-NEXT: s_mov_b32 s33, s3268; GCN-NEXT: s_or_saveexec_b64 s[18:19], -169; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill70; GCN-NEXT: s_mov_b64 exec, s[18:19]71; GCN-NEXT: v_writelane_b32 v40, s16, 272; GCN-NEXT: s_addk_i32 s32, 0x40073; GCN-NEXT: v_writelane_b32 v40, s30, 074; GCN-NEXT: s_getpc_b64 s[16:17]75; GCN-NEXT: s_add_u32 s16, s16, func_v3f32@rel32@lo+476; GCN-NEXT: s_addc_u32 s17, s17, func_v3f32@rel32@hi+1277; GCN-NEXT: v_writelane_b32 v40, s31, 178; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]79; GCN-NEXT: v_readlane_b32 s31, v40, 180; GCN-NEXT: v_readlane_b32 s30, v40, 081; GCN-NEXT: s_mov_b32 s32, s3382; GCN-NEXT: v_readlane_b32 s4, v40, 283; GCN-NEXT: s_or_saveexec_b64 s[6:7], -184; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload85; GCN-NEXT: s_mov_b64 exec, s[6:7]86; GCN-NEXT: s_mov_b32 s33, s487; GCN-NEXT: s_waitcnt vmcnt(0)88; GCN-NEXT: s_setpc_b64 s[30:31]89bb0:90 %split.ret.type = call <3 x float> @func_v3f32()91 br label %bb192 93bb1:94 %extract = extractelement <3 x float> %split.ret.type, i32 095 ret float %extract96}97 98define half @call_split_type_used_outside_block_v4f16() #0 {99; GCN-LABEL: call_split_type_used_outside_block_v4f16:100; GCN: ; %bb.0: ; %bb0101; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)102; GCN-NEXT: s_mov_b32 s16, s33103; GCN-NEXT: s_mov_b32 s33, s32104; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1105; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill106; GCN-NEXT: s_mov_b64 exec, s[18:19]107; GCN-NEXT: v_writelane_b32 v40, s16, 2108; GCN-NEXT: s_addk_i32 s32, 0x400109; GCN-NEXT: v_writelane_b32 v40, s30, 0110; GCN-NEXT: s_getpc_b64 s[16:17]111; GCN-NEXT: s_add_u32 s16, s16, func_v4f16@rel32@lo+4112; GCN-NEXT: s_addc_u32 s17, s17, func_v4f16@rel32@hi+12113; GCN-NEXT: v_writelane_b32 v40, s31, 1114; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]115; GCN-NEXT: v_readlane_b32 s31, v40, 1116; GCN-NEXT: v_readlane_b32 s30, v40, 0117; GCN-NEXT: s_mov_b32 s32, s33118; GCN-NEXT: v_readlane_b32 s4, v40, 2119; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1120; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload121; GCN-NEXT: s_mov_b64 exec, s[6:7]122; GCN-NEXT: s_mov_b32 s33, s4123; GCN-NEXT: s_waitcnt vmcnt(0)124; GCN-NEXT: s_setpc_b64 s[30:31]125bb0:126 %split.ret.type = call <4 x half> @func_v4f16()127 br label %bb1128 129bb1:130 %extract = extractelement <4 x half> %split.ret.type, i32 0131 ret half %extract132}133 134define { i32, half } @call_split_type_used_outside_block_struct() #0 {135; GCN-LABEL: call_split_type_used_outside_block_struct:136; GCN: ; %bb.0: ; %bb0137; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)138; GCN-NEXT: s_mov_b32 s16, s33139; GCN-NEXT: s_mov_b32 s33, s32140; GCN-NEXT: s_or_saveexec_b64 s[18:19], -1141; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill142; GCN-NEXT: s_mov_b64 exec, s[18:19]143; GCN-NEXT: v_writelane_b32 v40, s16, 2144; GCN-NEXT: s_addk_i32 s32, 0x400145; GCN-NEXT: v_writelane_b32 v40, s30, 0146; GCN-NEXT: s_getpc_b64 s[16:17]147; GCN-NEXT: s_add_u32 s16, s16, func_struct@rel32@lo+4148; GCN-NEXT: s_addc_u32 s17, s17, func_struct@rel32@hi+12149; GCN-NEXT: v_writelane_b32 v40, s31, 1150; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]151; GCN-NEXT: v_readlane_b32 s31, v40, 1152; GCN-NEXT: v_readlane_b32 s30, v40, 0153; GCN-NEXT: v_mov_b32_e32 v1, v4154; GCN-NEXT: s_mov_b32 s32, s33155; GCN-NEXT: v_readlane_b32 s4, v40, 2156; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1157; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload158; GCN-NEXT: s_mov_b64 exec, s[6:7]159; GCN-NEXT: s_mov_b32 s33, s4160; GCN-NEXT: s_waitcnt vmcnt(0)161; GCN-NEXT: s_setpc_b64 s[30:31]162bb0:163 %split.ret.type = call { <4 x i32>, <4 x half> } @func_struct()164 br label %bb1165 166bb1:167 %val0 = extractvalue { <4 x i32>, <4 x half> } %split.ret.type, 0168 %val1 = extractvalue { <4 x i32>, <4 x half> } %split.ret.type, 1169 %extract0 = extractelement <4 x i32> %val0, i32 0170 %extract1 = extractelement <4 x half> %val1, i32 0171 %ins0 = insertvalue { i32, half } poison, i32 %extract0, 0172 %ins1 = insertvalue { i32, half } %ins0, half %extract1, 1173 ret { i32, half } %ins1174}175 176define amdgpu_kernel void @v3i16_registers(i1 %cond) #0 {177; GCN-LABEL: v3i16_registers:178; GCN: ; %bb.0: ; %entry179; GCN-NEXT: s_add_u32 flat_scratch_lo, s12, s17180; GCN-NEXT: s_load_dword s12, s[8:9], 0x0181; GCN-NEXT: s_addc_u32 flat_scratch_hi, s13, 0182; GCN-NEXT: s_add_u32 s0, s0, s17183; GCN-NEXT: s_addc_u32 s1, s1, 0184; GCN-NEXT: s_mov_b32 s32, 0185; GCN-NEXT: s_waitcnt lgkmcnt(0)186; GCN-NEXT: s_bitcmp1_b32 s12, 0187; GCN-NEXT: s_cselect_b64 s[12:13], -1, 0188; GCN-NEXT: s_and_b64 vcc, exec, s[12:13]189; GCN-NEXT: s_cbranch_vccnz .LBB4_2190; GCN-NEXT: ; %bb.1: ; %if.else191; GCN-NEXT: s_add_u32 s8, s8, 8192; GCN-NEXT: s_addc_u32 s9, s9, 0193; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v2194; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v1195; GCN-NEXT: s_getpc_b64 s[18:19]196; GCN-NEXT: s_add_u32 s18, s18, func_v3i16@rel32@lo+4197; GCN-NEXT: s_addc_u32 s19, s19, func_v3i16@rel32@hi+12198; GCN-NEXT: v_or3_b32 v31, v0, v1, v2199; GCN-NEXT: s_mov_b32 s12, s14200; GCN-NEXT: s_mov_b32 s13, s15201; GCN-NEXT: s_mov_b32 s14, s16202; GCN-NEXT: s_swappc_b64 s[30:31], s[18:19]203; GCN-NEXT: s_branch .LBB4_3204; GCN-NEXT: .LBB4_2:205; GCN-NEXT: v_mov_b32_e32 v1, 0206; GCN-NEXT: v_mov_b32_e32 v0, 0207; GCN-NEXT: .LBB4_3: ; %if.end208; GCN-NEXT: global_store_short v[0:1], v1, off209; GCN-NEXT: global_store_dword v[0:1], v0, off210; GCN-NEXT: s_endpgm211entry:212 br i1 %cond, label %if.then, label %if.else213 214if.then: ; preds = %entry215 br label %if.end216 217if.else: ; preds = %entry218 %call6 = tail call <3 x i16> @func_v3i16() #0219 br label %if.end220 221if.end: ; preds = %if.else, %if.then222 %call6.sink = phi <3 x i16> [ %call6, %if.else ], [ zeroinitializer, %if.then ]223 store <3 x i16> %call6.sink, ptr addrspace(1) poison224 ret void225}226 227define amdgpu_kernel void @v3f16_registers(i1 %cond) #0 {228; GCN-LABEL: v3f16_registers:229; GCN: ; %bb.0: ; %entry230; GCN-NEXT: s_add_u32 flat_scratch_lo, s12, s17231; GCN-NEXT: s_load_dword s12, s[8:9], 0x0232; GCN-NEXT: s_addc_u32 flat_scratch_hi, s13, 0233; GCN-NEXT: s_add_u32 s0, s0, s17234; GCN-NEXT: s_addc_u32 s1, s1, 0235; GCN-NEXT: s_mov_b32 s32, 0236; GCN-NEXT: s_waitcnt lgkmcnt(0)237; GCN-NEXT: s_bitcmp1_b32 s12, 0238; GCN-NEXT: s_cselect_b64 s[12:13], -1, 0239; GCN-NEXT: s_and_b64 vcc, exec, s[12:13]240; GCN-NEXT: s_cbranch_vccnz .LBB5_2241; GCN-NEXT: ; %bb.1: ; %if.else242; GCN-NEXT: s_add_u32 s8, s8, 8243; GCN-NEXT: s_addc_u32 s9, s9, 0244; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v2245; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v1246; GCN-NEXT: s_getpc_b64 s[18:19]247; GCN-NEXT: s_add_u32 s18, s18, func_v3f16@rel32@lo+4248; GCN-NEXT: s_addc_u32 s19, s19, func_v3f16@rel32@hi+12249; GCN-NEXT: v_or3_b32 v31, v0, v1, v2250; GCN-NEXT: s_mov_b32 s12, s14251; GCN-NEXT: s_mov_b32 s13, s15252; GCN-NEXT: s_mov_b32 s14, s16253; GCN-NEXT: s_swappc_b64 s[30:31], s[18:19]254; GCN-NEXT: s_branch .LBB5_3255; GCN-NEXT: .LBB5_2:256; GCN-NEXT: v_mov_b32_e32 v1, 0257; GCN-NEXT: v_mov_b32_e32 v0, 0258; GCN-NEXT: .LBB5_3: ; %if.end259; GCN-NEXT: global_store_short v[0:1], v1, off260; GCN-NEXT: global_store_dword v[0:1], v0, off261; GCN-NEXT: s_endpgm262entry:263 br i1 %cond, label %if.then, label %if.else264 265if.then: ; preds = %entry266 br label %if.end267 268if.else: ; preds = %entry269 %call6 = tail call <3 x half> @func_v3f16() #0270 br label %if.end271 272if.end: ; preds = %if.else, %if.then273 %call6.sink = phi <3 x half> [ %call6, %if.else ], [ zeroinitializer, %if.then ]274 store <3 x half> %call6.sink, ptr addrspace(1) poison275 ret void276}277 278declare hidden <2 x float> @func_v2f32() #0279declare hidden <3 x float> @func_v3f32() #0280declare hidden <4 x float> @func_v4f32() #0281declare hidden <4 x half> @func_v4f16() #0282declare hidden <3 x i16> @func_v3i16()283declare hidden <3 x half> @func_v3f16()284 285declare hidden { <4 x i32>, <4 x half> } @func_struct() #0286 287attributes #0 = { nounwind}288 289