1522 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 62; RUN: opt -mcpu=kaveri -passes=amdgpu-attributor < %s | llc -enable-ipra=0 | FileCheck -enable-var-scope -check-prefixes=GCN %s3 4target triple = "amdgcn-amd-amdhsa"5 6define void @use_workitem_id_x() #1 {7; GCN-LABEL: use_workitem_id_x:8; GCN: ; %bb.0:9; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)10; GCN-NEXT: v_and_b32_e32 v0, 0x3ff, v3111; GCN-NEXT: flat_store_dword v[0:1], v012; GCN-NEXT: s_waitcnt vmcnt(0)13; GCN-NEXT: s_setpc_b64 s[30:31]14 %val = call i32 @llvm.amdgcn.workitem.id.x()15 store volatile i32 %val, ptr addrspace(1) poison16 ret void17}18 19define void @use_workitem_id_y() #1 {20; GCN-LABEL: use_workitem_id_y:21; GCN: ; %bb.0:22; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)23; GCN-NEXT: v_bfe_u32 v0, v31, 10, 1024; GCN-NEXT: flat_store_dword v[0:1], v025; GCN-NEXT: s_waitcnt vmcnt(0)26; GCN-NEXT: s_setpc_b64 s[30:31]27 %val = call i32 @llvm.amdgcn.workitem.id.y()28 store volatile i32 %val, ptr addrspace(1) poison29 ret void30}31 32define void @use_workitem_id_z() #1 {33; GCN-LABEL: use_workitem_id_z:34; GCN: ; %bb.0:35; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)36; GCN-NEXT: v_bfe_u32 v0, v31, 20, 1037; GCN-NEXT: flat_store_dword v[0:1], v038; GCN-NEXT: s_waitcnt vmcnt(0)39; GCN-NEXT: s_setpc_b64 s[30:31]40 %val = call i32 @llvm.amdgcn.workitem.id.z()41 store volatile i32 %val, ptr addrspace(1) poison42 ret void43}44 45define void @use_workitem_id_xy() #1 {46; GCN-LABEL: use_workitem_id_xy:47; GCN: ; %bb.0:48; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)49; GCN-NEXT: v_and_b32_e32 v0, 0x3ff, v3150; GCN-NEXT: flat_store_dword v[0:1], v051; GCN-NEXT: s_waitcnt vmcnt(0)52; GCN-NEXT: v_bfe_u32 v0, v31, 10, 1053; GCN-NEXT: flat_store_dword v[0:1], v054; GCN-NEXT: s_waitcnt vmcnt(0)55; GCN-NEXT: s_setpc_b64 s[30:31]56 %val0 = call i32 @llvm.amdgcn.workitem.id.x()57 %val1 = call i32 @llvm.amdgcn.workitem.id.y()58 store volatile i32 %val0, ptr addrspace(1) poison59 store volatile i32 %val1, ptr addrspace(1) poison60 ret void61}62 63define void @use_workitem_id_xyz() #1 {64; GCN-LABEL: use_workitem_id_xyz:65; GCN: ; %bb.0:66; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)67; GCN-NEXT: v_and_b32_e32 v0, 0x3ff, v3168; GCN-NEXT: flat_store_dword v[0:1], v069; GCN-NEXT: s_waitcnt vmcnt(0)70; GCN-NEXT: v_bfe_u32 v0, v31, 10, 1071; GCN-NEXT: flat_store_dword v[0:1], v072; GCN-NEXT: s_waitcnt vmcnt(0)73; GCN-NEXT: v_bfe_u32 v0, v31, 20, 1074; GCN-NEXT: flat_store_dword v[0:1], v075; GCN-NEXT: s_waitcnt vmcnt(0)76; GCN-NEXT: s_setpc_b64 s[30:31]77 %val0 = call i32 @llvm.amdgcn.workitem.id.x()78 %val1 = call i32 @llvm.amdgcn.workitem.id.y()79 %val2 = call i32 @llvm.amdgcn.workitem.id.z()80 store volatile i32 %val0, ptr addrspace(1) poison81 store volatile i32 %val1, ptr addrspace(1) poison82 store volatile i32 %val2, ptr addrspace(1) poison83 ret void84}85 86define void @use_workitem_id_xz() #1 {87; GCN-LABEL: use_workitem_id_xz:88; GCN: ; %bb.0:89; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)90; GCN-NEXT: v_and_b32_e32 v0, 0x3ff, v3191; GCN-NEXT: flat_store_dword v[0:1], v092; GCN-NEXT: s_waitcnt vmcnt(0)93; GCN-NEXT: v_bfe_u32 v0, v31, 20, 1094; GCN-NEXT: flat_store_dword v[0:1], v095; GCN-NEXT: s_waitcnt vmcnt(0)96; GCN-NEXT: s_setpc_b64 s[30:31]97 %val0 = call i32 @llvm.amdgcn.workitem.id.x()98 %val1 = call i32 @llvm.amdgcn.workitem.id.z()99 store volatile i32 %val0, ptr addrspace(1) poison100 store volatile i32 %val1, ptr addrspace(1) poison101 ret void102}103 104define void @use_workitem_id_yz() #1 {105; GCN-LABEL: use_workitem_id_yz:106; GCN: ; %bb.0:107; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)108; GCN-NEXT: v_bfe_u32 v0, v31, 10, 10109; GCN-NEXT: flat_store_dword v[0:1], v0110; GCN-NEXT: s_waitcnt vmcnt(0)111; GCN-NEXT: v_bfe_u32 v0, v31, 20, 10112; GCN-NEXT: flat_store_dword v[0:1], v0113; GCN-NEXT: s_waitcnt vmcnt(0)114; GCN-NEXT: s_setpc_b64 s[30:31]115 %val0 = call i32 @llvm.amdgcn.workitem.id.y()116 %val1 = call i32 @llvm.amdgcn.workitem.id.z()117 store volatile i32 %val0, ptr addrspace(1) poison118 store volatile i32 %val1, ptr addrspace(1) poison119 ret void120}121 122define amdgpu_kernel void @kern_indirect_use_workitem_id_x() #1 {123; GCN-LABEL: kern_indirect_use_workitem_id_x:124; GCN: ; %bb.0:125; GCN-NEXT: s_add_u32 s0, s0, s5126; GCN-NEXT: s_addc_u32 s1, s1, 0127; GCN-NEXT: s_getpc_b64 s[4:5]128; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_x@gotpcrel32@lo+4129; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_x@gotpcrel32@hi+12130; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0131; GCN-NEXT: v_mov_b32_e32 v31, v0132; GCN-NEXT: s_mov_b32 s32, 0133; GCN-NEXT: s_waitcnt lgkmcnt(0)134; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]135; GCN-NEXT: s_endpgm136 call void @use_workitem_id_x()137 ret void138}139; GCN: .amdhsa_system_vgpr_workitem_id 0140 141 142define amdgpu_kernel void @kern_indirect_use_workitem_id_y() #1 {143; GCN-LABEL: kern_indirect_use_workitem_id_y:144; GCN: ; %bb.0:145; GCN-NEXT: s_add_u32 s0, s0, s5146; GCN-NEXT: s_addc_u32 s1, s1, 0147; GCN-NEXT: s_getpc_b64 s[4:5]148; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_y@gotpcrel32@lo+4149; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_y@gotpcrel32@hi+12150; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0151; GCN-NEXT: v_lshlrev_b32_e32 v31, 10, v1152; GCN-NEXT: s_mov_b32 s32, 0153; GCN-NEXT: s_waitcnt lgkmcnt(0)154; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]155; GCN-NEXT: s_endpgm156 call void @use_workitem_id_y()157 ret void158}159; GCN: .amdhsa_system_vgpr_workitem_id 1160 161define amdgpu_kernel void @kern_indirect_use_workitem_id_z() #1 {162; GCN-LABEL: kern_indirect_use_workitem_id_z:163; GCN: ; %bb.0:164; GCN-NEXT: s_add_u32 s0, s0, s5165; GCN-NEXT: s_addc_u32 s1, s1, 0166; GCN-NEXT: s_getpc_b64 s[4:5]167; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_z@gotpcrel32@lo+4168; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_z@gotpcrel32@hi+12169; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0170; GCN-NEXT: v_lshlrev_b32_e32 v31, 20, v2171; GCN-NEXT: s_mov_b32 s32, 0172; GCN-NEXT: s_waitcnt lgkmcnt(0)173; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]174; GCN-NEXT: s_endpgm175 call void @use_workitem_id_z()176 ret void177}178; GCN: .amdhsa_system_vgpr_workitem_id 2179 180define amdgpu_kernel void @kern_indirect_use_workitem_id_xy() #1 {181; GCN-LABEL: kern_indirect_use_workitem_id_xy:182; GCN: ; %bb.0:183; GCN-NEXT: s_add_u32 s0, s0, s5184; GCN-NEXT: s_addc_u32 s1, s1, 0185; GCN-NEXT: s_getpc_b64 s[4:5]186; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_xy@gotpcrel32@lo+4187; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_xy@gotpcrel32@hi+12188; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0189; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v1190; GCN-NEXT: v_or_b32_e32 v31, v0, v1191; GCN-NEXT: s_mov_b32 s32, 0192; GCN-NEXT: s_waitcnt lgkmcnt(0)193; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]194; GCN-NEXT: s_endpgm195 call void @use_workitem_id_xy()196 ret void197}198 199define amdgpu_kernel void @kern_indirect_use_workitem_id_xz() #1 {200; GCN-LABEL: kern_indirect_use_workitem_id_xz:201; GCN: ; %bb.0:202; GCN-NEXT: s_add_u32 s0, s0, s5203; GCN-NEXT: s_addc_u32 s1, s1, 0204; GCN-NEXT: s_getpc_b64 s[4:5]205; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_xz@gotpcrel32@lo+4206; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_xz@gotpcrel32@hi+12207; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0208; GCN-NEXT: v_lshlrev_b32_e32 v1, 20, v2209; GCN-NEXT: v_or_b32_e32 v31, v0, v1210; GCN-NEXT: s_mov_b32 s32, 0211; GCN-NEXT: s_waitcnt lgkmcnt(0)212; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]213; GCN-NEXT: s_endpgm214 call void @use_workitem_id_xz()215 ret void216}217 218define amdgpu_kernel void @kern_indirect_use_workitem_id_yz() #1 {219; GCN-LABEL: kern_indirect_use_workitem_id_yz:220; GCN: ; %bb.0:221; GCN-NEXT: s_add_u32 s0, s0, s5222; GCN-NEXT: s_addc_u32 s1, s1, 0223; GCN-NEXT: s_getpc_b64 s[4:5]224; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_yz@gotpcrel32@lo+4225; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_yz@gotpcrel32@hi+12226; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0227; GCN-NEXT: v_lshlrev_b32_e32 v0, 20, v2228; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v1229; GCN-NEXT: v_or_b32_e32 v31, v1, v0230; GCN-NEXT: s_mov_b32 s32, 0231; GCN-NEXT: s_waitcnt lgkmcnt(0)232; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]233; GCN-NEXT: s_endpgm234 call void @use_workitem_id_yz()235 ret void236}237 238define amdgpu_kernel void @kern_indirect_use_workitem_id_xyz() #1 {239; GCN-LABEL: kern_indirect_use_workitem_id_xyz:240; GCN: ; %bb.0:241; GCN-NEXT: s_add_u32 s0, s0, s5242; GCN-NEXT: s_addc_u32 s1, s1, 0243; GCN-NEXT: s_getpc_b64 s[4:5]244; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_xyz@gotpcrel32@lo+4245; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_xyz@gotpcrel32@hi+12246; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0247; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v1248; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v2249; GCN-NEXT: v_or_b32_e32 v0, v0, v1250; GCN-NEXT: v_or_b32_e32 v31, v0, v2251; GCN-NEXT: s_mov_b32 s32, 0252; GCN-NEXT: s_waitcnt lgkmcnt(0)253; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]254; GCN-NEXT: s_endpgm255 call void @use_workitem_id_xyz()256 ret void257}258 259define void @func_indirect_use_workitem_id_x() #1 {260; GCN-LABEL: func_indirect_use_workitem_id_x:261; GCN: ; %bb.0:262; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)263; GCN-NEXT: s_mov_b32 s4, s33264; GCN-NEXT: s_mov_b32 s33, s32265; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1266; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill267; GCN-NEXT: s_mov_b64 exec, s[6:7]268; GCN-NEXT: s_addk_i32 s32, 0x400269; GCN-NEXT: v_writelane_b32 v40, s4, 2270; GCN-NEXT: s_getpc_b64 s[4:5]271; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_x@gotpcrel32@lo+4272; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_x@gotpcrel32@hi+12273; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0274; GCN-NEXT: v_writelane_b32 v40, s30, 0275; GCN-NEXT: v_writelane_b32 v40, s31, 1276; GCN-NEXT: s_waitcnt lgkmcnt(0)277; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]278; GCN-NEXT: v_readlane_b32 s31, v40, 1279; GCN-NEXT: v_readlane_b32 s30, v40, 0280; GCN-NEXT: s_mov_b32 s32, s33281; GCN-NEXT: v_readlane_b32 s4, v40, 2282; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1283; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload284; GCN-NEXT: s_mov_b64 exec, s[6:7]285; GCN-NEXT: s_mov_b32 s33, s4286; GCN-NEXT: s_waitcnt vmcnt(0)287; GCN-NEXT: s_setpc_b64 s[30:31]288 call void @use_workitem_id_x()289 ret void290}291 292define void @func_indirect_use_workitem_id_y() #1 {293; GCN-LABEL: func_indirect_use_workitem_id_y:294; GCN: ; %bb.0:295; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)296; GCN-NEXT: s_mov_b32 s4, s33297; GCN-NEXT: s_mov_b32 s33, s32298; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1299; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill300; GCN-NEXT: s_mov_b64 exec, s[6:7]301; GCN-NEXT: s_addk_i32 s32, 0x400302; GCN-NEXT: v_writelane_b32 v40, s4, 2303; GCN-NEXT: s_getpc_b64 s[4:5]304; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_y@gotpcrel32@lo+4305; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_y@gotpcrel32@hi+12306; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0307; GCN-NEXT: v_writelane_b32 v40, s30, 0308; GCN-NEXT: v_writelane_b32 v40, s31, 1309; GCN-NEXT: s_waitcnt lgkmcnt(0)310; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]311; GCN-NEXT: v_readlane_b32 s31, v40, 1312; GCN-NEXT: v_readlane_b32 s30, v40, 0313; GCN-NEXT: s_mov_b32 s32, s33314; GCN-NEXT: v_readlane_b32 s4, v40, 2315; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1316; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload317; GCN-NEXT: s_mov_b64 exec, s[6:7]318; GCN-NEXT: s_mov_b32 s33, s4319; GCN-NEXT: s_waitcnt vmcnt(0)320; GCN-NEXT: s_setpc_b64 s[30:31]321 call void @use_workitem_id_y()322 ret void323}324 325define void @func_indirect_use_workitem_id_z() #1 {326; GCN-LABEL: func_indirect_use_workitem_id_z:327; GCN: ; %bb.0:328; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)329; GCN-NEXT: s_mov_b32 s4, s33330; GCN-NEXT: s_mov_b32 s33, s32331; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1332; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill333; GCN-NEXT: s_mov_b64 exec, s[6:7]334; GCN-NEXT: s_addk_i32 s32, 0x400335; GCN-NEXT: v_writelane_b32 v40, s4, 2336; GCN-NEXT: s_getpc_b64 s[4:5]337; GCN-NEXT: s_add_u32 s4, s4, use_workitem_id_z@gotpcrel32@lo+4338; GCN-NEXT: s_addc_u32 s5, s5, use_workitem_id_z@gotpcrel32@hi+12339; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0340; GCN-NEXT: v_writelane_b32 v40, s30, 0341; GCN-NEXT: v_writelane_b32 v40, s31, 1342; GCN-NEXT: s_waitcnt lgkmcnt(0)343; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]344; GCN-NEXT: v_readlane_b32 s31, v40, 1345; GCN-NEXT: v_readlane_b32 s30, v40, 0346; GCN-NEXT: s_mov_b32 s32, s33347; GCN-NEXT: v_readlane_b32 s4, v40, 2348; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1349; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload350; GCN-NEXT: s_mov_b64 exec, s[6:7]351; GCN-NEXT: s_mov_b32 s33, s4352; GCN-NEXT: s_waitcnt vmcnt(0)353; GCN-NEXT: s_setpc_b64 s[30:31]354 call void @use_workitem_id_z()355 ret void356}357 358define void @other_arg_use_workitem_id_x(i32 %arg0) #1 {359; GCN-LABEL: other_arg_use_workitem_id_x:360; GCN: ; %bb.0:361; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)362; GCN-NEXT: flat_store_dword v[0:1], v0363; GCN-NEXT: s_waitcnt vmcnt(0)364; GCN-NEXT: v_and_b32_e32 v0, 0x3ff, v31365; GCN-NEXT: flat_store_dword v[0:1], v0366; GCN-NEXT: s_waitcnt vmcnt(0)367; GCN-NEXT: s_setpc_b64 s[30:31]368 %val = call i32 @llvm.amdgcn.workitem.id.x()369 store volatile i32 %arg0, ptr addrspace(1) poison370 store volatile i32 %val, ptr addrspace(1) poison371 ret void372}373 374define void @other_arg_use_workitem_id_y(i32 %arg0) #1 {375; GCN-LABEL: other_arg_use_workitem_id_y:376; GCN: ; %bb.0:377; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)378; GCN-NEXT: flat_store_dword v[0:1], v0379; GCN-NEXT: s_waitcnt vmcnt(0)380; GCN-NEXT: v_bfe_u32 v0, v31, 10, 10381; GCN-NEXT: flat_store_dword v[0:1], v0382; GCN-NEXT: s_waitcnt vmcnt(0)383; GCN-NEXT: s_setpc_b64 s[30:31]384 %val = call i32 @llvm.amdgcn.workitem.id.y()385 store volatile i32 %arg0, ptr addrspace(1) poison386 store volatile i32 %val, ptr addrspace(1) poison387 ret void388}389 390define void @other_arg_use_workitem_id_z(i32 %arg0) #1 {391; GCN-LABEL: other_arg_use_workitem_id_z:392; GCN: ; %bb.0:393; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)394; GCN-NEXT: flat_store_dword v[0:1], v0395; GCN-NEXT: s_waitcnt vmcnt(0)396; GCN-NEXT: v_bfe_u32 v0, v31, 20, 10397; GCN-NEXT: flat_store_dword v[0:1], v0398; GCN-NEXT: s_waitcnt vmcnt(0)399; GCN-NEXT: s_setpc_b64 s[30:31]400 %val = call i32 @llvm.amdgcn.workitem.id.z()401 store volatile i32 %arg0, ptr addrspace(1) poison402 store volatile i32 %val, ptr addrspace(1) poison403 ret void404}405 406define amdgpu_kernel void @kern_indirect_other_arg_use_workitem_id_x() #1 {407; GCN-LABEL: kern_indirect_other_arg_use_workitem_id_x:408; GCN: ; %bb.0:409; GCN-NEXT: s_add_u32 s0, s0, s5410; GCN-NEXT: s_addc_u32 s1, s1, 0411; GCN-NEXT: s_getpc_b64 s[4:5]412; GCN-NEXT: s_add_u32 s4, s4, other_arg_use_workitem_id_x@gotpcrel32@lo+4413; GCN-NEXT: s_addc_u32 s5, s5, other_arg_use_workitem_id_x@gotpcrel32@hi+12414; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0415; GCN-NEXT: v_mov_b32_e32 v31, v0416; GCN-NEXT: v_mov_b32_e32 v0, 0x22b417; GCN-NEXT: s_mov_b32 s32, 0418; GCN-NEXT: s_waitcnt lgkmcnt(0)419; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]420; GCN-NEXT: s_endpgm421 call void @other_arg_use_workitem_id_x(i32 555)422 ret void423}424; GCN: .amdhsa_system_vgpr_workitem_id 0425 426define amdgpu_kernel void @kern_indirect_other_arg_use_workitem_id_y() #1 {427; GCN-LABEL: kern_indirect_other_arg_use_workitem_id_y:428; GCN: ; %bb.0:429; GCN-NEXT: s_add_u32 s0, s0, s5430; GCN-NEXT: s_addc_u32 s1, s1, 0431; GCN-NEXT: s_getpc_b64 s[4:5]432; GCN-NEXT: s_add_u32 s4, s4, other_arg_use_workitem_id_y@gotpcrel32@lo+4433; GCN-NEXT: s_addc_u32 s5, s5, other_arg_use_workitem_id_y@gotpcrel32@hi+12434; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0435; GCN-NEXT: v_lshlrev_b32_e32 v31, 10, v1436; GCN-NEXT: v_mov_b32_e32 v0, 0x22b437; GCN-NEXT: s_mov_b32 s32, 0438; GCN-NEXT: s_waitcnt lgkmcnt(0)439; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]440; GCN-NEXT: s_endpgm441 call void @other_arg_use_workitem_id_y(i32 555)442 ret void443}444; GCN: .amdhsa_system_vgpr_workitem_id 1445 446define amdgpu_kernel void @kern_indirect_other_arg_use_workitem_id_z() #1 {447; GCN-LABEL: kern_indirect_other_arg_use_workitem_id_z:448; GCN: ; %bb.0:449; GCN-NEXT: s_add_u32 s0, s0, s5450; GCN-NEXT: s_addc_u32 s1, s1, 0451; GCN-NEXT: s_getpc_b64 s[4:5]452; GCN-NEXT: s_add_u32 s4, s4, other_arg_use_workitem_id_z@gotpcrel32@lo+4453; GCN-NEXT: s_addc_u32 s5, s5, other_arg_use_workitem_id_z@gotpcrel32@hi+12454; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0455; GCN-NEXT: v_lshlrev_b32_e32 v31, 20, v2456; GCN-NEXT: v_mov_b32_e32 v0, 0x22b457; GCN-NEXT: s_mov_b32 s32, 0458; GCN-NEXT: s_waitcnt lgkmcnt(0)459; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]460; GCN-NEXT: s_endpgm461 call void @other_arg_use_workitem_id_z(i32 555)462 ret void463}464; GCN: .amdhsa_system_vgpr_workitem_id 2465 466define void @too_many_args_use_workitem_id_x(467; GCN-LABEL: too_many_args_use_workitem_id_x:468; GCN: ; %bb.0:469; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)470; GCN-NEXT: v_and_b32_e32 v31, 0x3ff, v31471; GCN-NEXT: flat_store_dword v[0:1], v31472; GCN-NEXT: s_waitcnt vmcnt(0)473; GCN-NEXT: buffer_load_dword v31, off, s[0:3], s32474; GCN-NEXT: flat_store_dword v[0:1], v0475; GCN-NEXT: s_waitcnt vmcnt(0)476; GCN-NEXT: flat_store_dword v[0:1], v1477; GCN-NEXT: s_waitcnt vmcnt(0)478; GCN-NEXT: flat_store_dword v[0:1], v2479; GCN-NEXT: s_waitcnt vmcnt(0)480; GCN-NEXT: flat_store_dword v[0:1], v3481; GCN-NEXT: s_waitcnt vmcnt(0)482; GCN-NEXT: flat_store_dword v[0:1], v4483; GCN-NEXT: s_waitcnt vmcnt(0)484; GCN-NEXT: flat_store_dword v[0:1], v5485; GCN-NEXT: s_waitcnt vmcnt(0)486; GCN-NEXT: flat_store_dword v[0:1], v6487; GCN-NEXT: s_waitcnt vmcnt(0)488; GCN-NEXT: flat_store_dword v[0:1], v7489; GCN-NEXT: s_waitcnt vmcnt(0)490; GCN-NEXT: flat_store_dword v[0:1], v8491; GCN-NEXT: s_waitcnt vmcnt(0)492; GCN-NEXT: flat_store_dword v[0:1], v9493; GCN-NEXT: s_waitcnt vmcnt(0)494; GCN-NEXT: flat_store_dword v[0:1], v10495; GCN-NEXT: s_waitcnt vmcnt(0)496; GCN-NEXT: flat_store_dword v[0:1], v11497; GCN-NEXT: s_waitcnt vmcnt(0)498; GCN-NEXT: flat_store_dword v[0:1], v12499; GCN-NEXT: s_waitcnt vmcnt(0)500; GCN-NEXT: flat_store_dword v[0:1], v13501; GCN-NEXT: s_waitcnt vmcnt(0)502; GCN-NEXT: flat_store_dword v[0:1], v14503; GCN-NEXT: s_waitcnt vmcnt(0)504; GCN-NEXT: flat_store_dword v[0:1], v15505; GCN-NEXT: s_waitcnt vmcnt(0)506; GCN-NEXT: flat_store_dword v[0:1], v16507; GCN-NEXT: s_waitcnt vmcnt(0)508; GCN-NEXT: flat_store_dword v[0:1], v17509; GCN-NEXT: s_waitcnt vmcnt(0)510; GCN-NEXT: flat_store_dword v[0:1], v18511; GCN-NEXT: s_waitcnt vmcnt(0)512; GCN-NEXT: flat_store_dword v[0:1], v19513; GCN-NEXT: s_waitcnt vmcnt(0)514; GCN-NEXT: flat_store_dword v[0:1], v20515; GCN-NEXT: s_waitcnt vmcnt(0)516; GCN-NEXT: flat_store_dword v[0:1], v21517; GCN-NEXT: s_waitcnt vmcnt(0)518; GCN-NEXT: flat_store_dword v[0:1], v22519; GCN-NEXT: s_waitcnt vmcnt(0)520; GCN-NEXT: flat_store_dword v[0:1], v23521; GCN-NEXT: s_waitcnt vmcnt(0)522; GCN-NEXT: flat_store_dword v[0:1], v24523; GCN-NEXT: s_waitcnt vmcnt(0)524; GCN-NEXT: flat_store_dword v[0:1], v25525; GCN-NEXT: s_waitcnt vmcnt(0)526; GCN-NEXT: flat_store_dword v[0:1], v26527; GCN-NEXT: s_waitcnt vmcnt(0)528; GCN-NEXT: flat_store_dword v[0:1], v27529; GCN-NEXT: s_waitcnt vmcnt(0)530; GCN-NEXT: flat_store_dword v[0:1], v28531; GCN-NEXT: s_waitcnt vmcnt(0)532; GCN-NEXT: flat_store_dword v[0:1], v29533; GCN-NEXT: s_waitcnt vmcnt(0)534; GCN-NEXT: flat_store_dword v[0:1], v30535; GCN-NEXT: s_waitcnt vmcnt(0)536; GCN-NEXT: flat_store_dword v[0:1], v31537; GCN-NEXT: s_waitcnt vmcnt(0)538; GCN-NEXT: s_setpc_b64 s[30:31]539 i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7,540 i32 %arg8, i32 %arg9, i32 %arg10, i32 %arg11, i32 %arg12, i32 %arg13, i32 %arg14, i32 %arg15,541 i32 %arg16, i32 %arg17, i32 %arg18, i32 %arg19, i32 %arg20, i32 %arg21, i32 %arg22, i32 %arg23,542 i32 %arg24, i32 %arg25, i32 %arg26, i32 %arg27, i32 %arg28, i32 %arg29, i32 %arg30, i32 %arg31) #1 {543 %val = call i32 @llvm.amdgcn.workitem.id.x()544 store volatile i32 %val, ptr addrspace(1) poison545 546 store volatile i32 %arg0, ptr addrspace(1) poison547 store volatile i32 %arg1, ptr addrspace(1) poison548 store volatile i32 %arg2, ptr addrspace(1) poison549 store volatile i32 %arg3, ptr addrspace(1) poison550 store volatile i32 %arg4, ptr addrspace(1) poison551 store volatile i32 %arg5, ptr addrspace(1) poison552 store volatile i32 %arg6, ptr addrspace(1) poison553 store volatile i32 %arg7, ptr addrspace(1) poison554 555 store volatile i32 %arg8, ptr addrspace(1) poison556 store volatile i32 %arg9, ptr addrspace(1) poison557 store volatile i32 %arg10, ptr addrspace(1) poison558 store volatile i32 %arg11, ptr addrspace(1) poison559 store volatile i32 %arg12, ptr addrspace(1) poison560 store volatile i32 %arg13, ptr addrspace(1) poison561 store volatile i32 %arg14, ptr addrspace(1) poison562 store volatile i32 %arg15, ptr addrspace(1) poison563 564 store volatile i32 %arg16, ptr addrspace(1) poison565 store volatile i32 %arg17, ptr addrspace(1) poison566 store volatile i32 %arg18, ptr addrspace(1) poison567 store volatile i32 %arg19, ptr addrspace(1) poison568 store volatile i32 %arg20, ptr addrspace(1) poison569 store volatile i32 %arg21, ptr addrspace(1) poison570 store volatile i32 %arg22, ptr addrspace(1) poison571 store volatile i32 %arg23, ptr addrspace(1) poison572 573 store volatile i32 %arg24, ptr addrspace(1) poison574 store volatile i32 %arg25, ptr addrspace(1) poison575 store volatile i32 %arg26, ptr addrspace(1) poison576 store volatile i32 %arg27, ptr addrspace(1) poison577 store volatile i32 %arg28, ptr addrspace(1) poison578 store volatile i32 %arg29, ptr addrspace(1) poison579 store volatile i32 %arg30, ptr addrspace(1) poison580 store volatile i32 %arg31, ptr addrspace(1) poison581 582 ret void583}584 585define amdgpu_kernel void @kern_call_too_many_args_use_workitem_id_x() #1 {586; GCN-LABEL: kern_call_too_many_args_use_workitem_id_x:587; GCN: ; %bb.0:588; GCN-NEXT: s_add_u32 s0, s0, s5589; GCN-NEXT: s_addc_u32 s1, s1, 0590; GCN-NEXT: s_getpc_b64 s[4:5]591; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_x@gotpcrel32@lo+4592; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_x@gotpcrel32@hi+12593; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0594; GCN-NEXT: s_mov_b32 s32, 0595; GCN-NEXT: v_mov_b32_e32 v1, 0x140596; GCN-NEXT: buffer_store_dword v1, off, s[0:3], s32597; GCN-NEXT: v_mov_b32_e32 v31, v0598; GCN-NEXT: v_mov_b32_e32 v0, 10599; GCN-NEXT: v_mov_b32_e32 v1, 20600; GCN-NEXT: v_mov_b32_e32 v2, 30601; GCN-NEXT: v_mov_b32_e32 v3, 40602; GCN-NEXT: v_mov_b32_e32 v4, 50603; GCN-NEXT: v_mov_b32_e32 v5, 60604; GCN-NEXT: v_mov_b32_e32 v6, 0x46605; GCN-NEXT: v_mov_b32_e32 v7, 0x50606; GCN-NEXT: v_mov_b32_e32 v8, 0x5a607; GCN-NEXT: v_mov_b32_e32 v9, 0x64608; GCN-NEXT: v_mov_b32_e32 v10, 0x6e609; GCN-NEXT: v_mov_b32_e32 v11, 0x78610; GCN-NEXT: v_mov_b32_e32 v12, 0x82611; GCN-NEXT: v_mov_b32_e32 v13, 0x8c612; GCN-NEXT: v_mov_b32_e32 v14, 0x96613; GCN-NEXT: v_mov_b32_e32 v15, 0xa0614; GCN-NEXT: v_mov_b32_e32 v16, 0xaa615; GCN-NEXT: v_mov_b32_e32 v17, 0xb4616; GCN-NEXT: v_mov_b32_e32 v18, 0xbe617; GCN-NEXT: v_mov_b32_e32 v19, 0xc8618; GCN-NEXT: v_mov_b32_e32 v20, 0xd2619; GCN-NEXT: v_mov_b32_e32 v21, 0xdc620; GCN-NEXT: v_mov_b32_e32 v22, 0xe6621; GCN-NEXT: v_mov_b32_e32 v23, 0xf0622; GCN-NEXT: v_mov_b32_e32 v24, 0xfa623; GCN-NEXT: v_mov_b32_e32 v25, 0x104624; GCN-NEXT: v_mov_b32_e32 v26, 0x10e625; GCN-NEXT: v_mov_b32_e32 v27, 0x118626; GCN-NEXT: v_mov_b32_e32 v28, 0x122627; GCN-NEXT: v_mov_b32_e32 v29, 0x12c628; GCN-NEXT: v_mov_b32_e32 v30, 0x136629; GCN-NEXT: s_waitcnt lgkmcnt(0)630; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]631; GCN-NEXT: s_endpgm632 call void @too_many_args_use_workitem_id_x(633 i32 10, i32 20, i32 30, i32 40,634 i32 50, i32 60, i32 70, i32 80,635 i32 90, i32 100, i32 110, i32 120,636 i32 130, i32 140, i32 150, i32 160,637 i32 170, i32 180, i32 190, i32 200,638 i32 210, i32 220, i32 230, i32 240,639 i32 250, i32 260, i32 270, i32 280,640 i32 290, i32 300, i32 310, i32 320)641 ret void642}643; GCN: .amdhsa_system_vgpr_workitem_id 0644 645define void @func_call_too_many_args_use_workitem_id_x(i32 %arg0) #1 {646; GCN-LABEL: func_call_too_many_args_use_workitem_id_x:647; GCN: ; %bb.0:648; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)649; GCN-NEXT: s_mov_b32 s4, s33650; GCN-NEXT: s_mov_b32 s33, s32651; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1652; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill653; GCN-NEXT: s_mov_b64 exec, s[6:7]654; GCN-NEXT: s_addk_i32 s32, 0x400655; GCN-NEXT: v_writelane_b32 v40, s4, 2656; GCN-NEXT: s_getpc_b64 s[4:5]657; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_x@gotpcrel32@lo+4658; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_x@gotpcrel32@hi+12659; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0660; GCN-NEXT: flat_store_dword v[0:1], v0661; GCN-NEXT: s_waitcnt vmcnt(0)662; GCN-NEXT: v_mov_b32_e32 v0, 0x140663; GCN-NEXT: v_writelane_b32 v40, s30, 0664; GCN-NEXT: buffer_store_dword v0, off, s[0:3], s32665; GCN-NEXT: v_mov_b32_e32 v0, 10666; GCN-NEXT: v_mov_b32_e32 v1, 20667; GCN-NEXT: v_mov_b32_e32 v2, 30668; GCN-NEXT: v_mov_b32_e32 v3, 40669; GCN-NEXT: v_mov_b32_e32 v4, 50670; GCN-NEXT: v_mov_b32_e32 v5, 60671; GCN-NEXT: v_mov_b32_e32 v6, 0x46672; GCN-NEXT: v_mov_b32_e32 v7, 0x50673; GCN-NEXT: v_mov_b32_e32 v8, 0x5a674; GCN-NEXT: v_mov_b32_e32 v9, 0x64675; GCN-NEXT: v_mov_b32_e32 v10, 0x6e676; GCN-NEXT: v_mov_b32_e32 v11, 0x78677; GCN-NEXT: v_mov_b32_e32 v12, 0x82678; GCN-NEXT: v_mov_b32_e32 v13, 0x8c679; GCN-NEXT: v_mov_b32_e32 v14, 0x96680; GCN-NEXT: v_mov_b32_e32 v15, 0xa0681; GCN-NEXT: v_mov_b32_e32 v16, 0xaa682; GCN-NEXT: v_mov_b32_e32 v17, 0xb4683; GCN-NEXT: v_mov_b32_e32 v18, 0xbe684; GCN-NEXT: v_mov_b32_e32 v19, 0xc8685; GCN-NEXT: v_mov_b32_e32 v20, 0xd2686; GCN-NEXT: v_mov_b32_e32 v21, 0xdc687; GCN-NEXT: v_mov_b32_e32 v22, 0xe6688; GCN-NEXT: v_mov_b32_e32 v23, 0xf0689; GCN-NEXT: v_mov_b32_e32 v24, 0xfa690; GCN-NEXT: v_mov_b32_e32 v25, 0x104691; GCN-NEXT: v_mov_b32_e32 v26, 0x10e692; GCN-NEXT: v_mov_b32_e32 v27, 0x118693; GCN-NEXT: v_mov_b32_e32 v28, 0x122694; GCN-NEXT: v_mov_b32_e32 v29, 0x12c695; GCN-NEXT: v_mov_b32_e32 v30, 0x136696; GCN-NEXT: v_writelane_b32 v40, s31, 1697; GCN-NEXT: s_waitcnt lgkmcnt(0)698; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]699; GCN-NEXT: v_readlane_b32 s31, v40, 1700; GCN-NEXT: v_readlane_b32 s30, v40, 0701; GCN-NEXT: s_mov_b32 s32, s33702; GCN-NEXT: v_readlane_b32 s4, v40, 2703; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1704; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload705; GCN-NEXT: s_mov_b64 exec, s[6:7]706; GCN-NEXT: s_mov_b32 s33, s4707; GCN-NEXT: s_waitcnt vmcnt(0)708; GCN-NEXT: s_setpc_b64 s[30:31]709 store volatile i32 %arg0, ptr addrspace(1) poison710 call void @too_many_args_use_workitem_id_x(711 i32 10, i32 20, i32 30, i32 40,712 i32 50, i32 60, i32 70, i32 80,713 i32 90, i32 100, i32 110, i32 120,714 i32 130, i32 140, i32 150, i32 160,715 i32 170, i32 180, i32 190, i32 200,716 i32 210, i32 220, i32 230, i32 240,717 i32 250, i32 260, i32 270, i32 280,718 i32 290, i32 300, i32 310, i32 320)719 ret void720}721 722; Requires loading and storing to stack slot.723define void @too_many_args_call_too_many_args_use_workitem_id_x(724; GCN-LABEL: too_many_args_call_too_many_args_use_workitem_id_x:725; GCN: ; %bb.0:726; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)727; GCN-NEXT: s_mov_b32 s4, s33728; GCN-NEXT: s_mov_b32 s33, s32729; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1730; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill731; GCN-NEXT: s_mov_b64 exec, s[6:7]732; GCN-NEXT: buffer_load_dword v32, off, s[0:3], s33733; GCN-NEXT: s_addk_i32 s32, 0x400734; GCN-NEXT: v_writelane_b32 v40, s4, 2735; GCN-NEXT: s_getpc_b64 s[4:5]736; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_x@gotpcrel32@lo+4737; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_x@gotpcrel32@hi+12738; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0739; GCN-NEXT: v_writelane_b32 v40, s30, 0740; GCN-NEXT: v_writelane_b32 v40, s31, 1741; GCN-NEXT: s_waitcnt vmcnt(0)742; GCN-NEXT: buffer_store_dword v32, off, s[0:3], s32743; GCN-NEXT: s_waitcnt lgkmcnt(0)744; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]745; GCN-NEXT: v_readlane_b32 s31, v40, 1746; GCN-NEXT: v_readlane_b32 s30, v40, 0747; GCN-NEXT: s_mov_b32 s32, s33748; GCN-NEXT: v_readlane_b32 s4, v40, 2749; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1750; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload751; GCN-NEXT: s_mov_b64 exec, s[6:7]752; GCN-NEXT: s_mov_b32 s33, s4753; GCN-NEXT: s_waitcnt vmcnt(0)754; GCN-NEXT: s_setpc_b64 s[30:31]755 i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7,756 i32 %arg8, i32 %arg9, i32 %arg10, i32 %arg11, i32 %arg12, i32 %arg13, i32 %arg14, i32 %arg15,757 i32 %arg16, i32 %arg17, i32 %arg18, i32 %arg19, i32 %arg20, i32 %arg21, i32 %arg22, i32 %arg23,758 i32 %arg24, i32 %arg25, i32 %arg26, i32 %arg27, i32 %arg28, i32 %arg29, i32 %arg30, i32 %arg31) #1 {759 call void @too_many_args_use_workitem_id_x(760 i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7,761 i32 %arg8, i32 %arg9, i32 %arg10, i32 %arg11, i32 %arg12, i32 %arg13, i32 %arg14, i32 %arg15,762 i32 %arg16, i32 %arg17, i32 %arg18, i32 %arg19, i32 %arg20, i32 %arg21, i32 %arg22, i32 %arg23,763 i32 %arg24, i32 %arg25, i32 %arg26, i32 %arg27, i32 %arg28, i32 %arg29, i32 %arg30, i32 %arg31)764 ret void765}766 767; var abi stack layout:768; frame[0] = byval arg32769; frame[1] = stack passed workitem ID x770; frame[2] = VGPR spill slot771define void @too_many_args_use_workitem_id_x_byval(772; GCN-LABEL: too_many_args_use_workitem_id_x_byval:773; GCN: ; %bb.0:774; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)775; GCN-NEXT: v_and_b32_e32 v31, 0x3ff, v31776; GCN-NEXT: flat_store_dword v[0:1], v31777; GCN-NEXT: s_waitcnt vmcnt(0)778; GCN-NEXT: buffer_load_dword v31, off, s[0:3], s32779; GCN-NEXT: flat_store_dword v[0:1], v0780; GCN-NEXT: s_waitcnt vmcnt(0)781; GCN-NEXT: flat_store_dword v[0:1], v1782; GCN-NEXT: s_waitcnt vmcnt(0)783; GCN-NEXT: flat_store_dword v[0:1], v2784; GCN-NEXT: s_waitcnt vmcnt(0)785; GCN-NEXT: flat_store_dword v[0:1], v3786; GCN-NEXT: s_waitcnt vmcnt(0)787; GCN-NEXT: flat_store_dword v[0:1], v4788; GCN-NEXT: s_waitcnt vmcnt(0)789; GCN-NEXT: flat_store_dword v[0:1], v5790; GCN-NEXT: s_waitcnt vmcnt(0)791; GCN-NEXT: flat_store_dword v[0:1], v6792; GCN-NEXT: s_waitcnt vmcnt(0)793; GCN-NEXT: flat_store_dword v[0:1], v7794; GCN-NEXT: s_waitcnt vmcnt(0)795; GCN-NEXT: flat_store_dword v[0:1], v8796; GCN-NEXT: s_waitcnt vmcnt(0)797; GCN-NEXT: flat_store_dword v[0:1], v9798; GCN-NEXT: s_waitcnt vmcnt(0)799; GCN-NEXT: flat_store_dword v[0:1], v10800; GCN-NEXT: s_waitcnt vmcnt(0)801; GCN-NEXT: flat_store_dword v[0:1], v11802; GCN-NEXT: s_waitcnt vmcnt(0)803; GCN-NEXT: flat_store_dword v[0:1], v12804; GCN-NEXT: s_waitcnt vmcnt(0)805; GCN-NEXT: flat_store_dword v[0:1], v13806; GCN-NEXT: s_waitcnt vmcnt(0)807; GCN-NEXT: flat_store_dword v[0:1], v14808; GCN-NEXT: s_waitcnt vmcnt(0)809; GCN-NEXT: flat_store_dword v[0:1], v15810; GCN-NEXT: s_waitcnt vmcnt(0)811; GCN-NEXT: flat_store_dword v[0:1], v16812; GCN-NEXT: s_waitcnt vmcnt(0)813; GCN-NEXT: flat_store_dword v[0:1], v17814; GCN-NEXT: s_waitcnt vmcnt(0)815; GCN-NEXT: flat_store_dword v[0:1], v18816; GCN-NEXT: s_waitcnt vmcnt(0)817; GCN-NEXT: flat_store_dword v[0:1], v19818; GCN-NEXT: s_waitcnt vmcnt(0)819; GCN-NEXT: flat_store_dword v[0:1], v20820; GCN-NEXT: s_waitcnt vmcnt(0)821; GCN-NEXT: flat_store_dword v[0:1], v21822; GCN-NEXT: s_waitcnt vmcnt(0)823; GCN-NEXT: flat_store_dword v[0:1], v22824; GCN-NEXT: s_waitcnt vmcnt(0)825; GCN-NEXT: flat_store_dword v[0:1], v23826; GCN-NEXT: s_waitcnt vmcnt(0)827; GCN-NEXT: flat_store_dword v[0:1], v24828; GCN-NEXT: s_waitcnt vmcnt(0)829; GCN-NEXT: flat_store_dword v[0:1], v25830; GCN-NEXT: s_waitcnt vmcnt(0)831; GCN-NEXT: flat_store_dword v[0:1], v26832; GCN-NEXT: s_waitcnt vmcnt(0)833; GCN-NEXT: flat_store_dword v[0:1], v27834; GCN-NEXT: s_waitcnt vmcnt(0)835; GCN-NEXT: flat_store_dword v[0:1], v28836; GCN-NEXT: s_waitcnt vmcnt(0)837; GCN-NEXT: flat_store_dword v[0:1], v29838; GCN-NEXT: s_waitcnt vmcnt(0)839; GCN-NEXT: flat_store_dword v[0:1], v30840; GCN-NEXT: s_waitcnt vmcnt(0)841; GCN-NEXT: flat_store_dword v[0:1], v31842; GCN-NEXT: s_waitcnt vmcnt(0)843; GCN-NEXT: buffer_load_dword v0, off, s[0:3], s32 offset:4 glc844; GCN-NEXT: s_waitcnt vmcnt(0)845; GCN-NEXT: s_setpc_b64 s[30:31]846 i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7,847 i32 %arg8, i32 %arg9, i32 %arg10, i32 %arg11, i32 %arg12, i32 %arg13, i32 %arg14, i32 %arg15,848 i32 %arg16, i32 %arg17, i32 %arg18, i32 %arg19, i32 %arg20, i32 %arg21, i32 %arg22, i32 %arg23,849 i32 %arg24, i32 %arg25, i32 %arg26, i32 %arg27, i32 %arg28, i32 %arg29, i32 %arg30, i32 %arg31, ptr addrspace(5) byval(i32) %arg32) #1 {850 %val = call i32 @llvm.amdgcn.workitem.id.x()851 store volatile i32 %val, ptr addrspace(1) poison852 853 store volatile i32 %arg0, ptr addrspace(1) poison854 store volatile i32 %arg1, ptr addrspace(1) poison855 store volatile i32 %arg2, ptr addrspace(1) poison856 store volatile i32 %arg3, ptr addrspace(1) poison857 store volatile i32 %arg4, ptr addrspace(1) poison858 store volatile i32 %arg5, ptr addrspace(1) poison859 store volatile i32 %arg6, ptr addrspace(1) poison860 store volatile i32 %arg7, ptr addrspace(1) poison861 862 store volatile i32 %arg8, ptr addrspace(1) poison863 store volatile i32 %arg9, ptr addrspace(1) poison864 store volatile i32 %arg10, ptr addrspace(1) poison865 store volatile i32 %arg11, ptr addrspace(1) poison866 store volatile i32 %arg12, ptr addrspace(1) poison867 store volatile i32 %arg13, ptr addrspace(1) poison868 store volatile i32 %arg14, ptr addrspace(1) poison869 store volatile i32 %arg15, ptr addrspace(1) poison870 871 store volatile i32 %arg16, ptr addrspace(1) poison872 store volatile i32 %arg17, ptr addrspace(1) poison873 store volatile i32 %arg18, ptr addrspace(1) poison874 store volatile i32 %arg19, ptr addrspace(1) poison875 store volatile i32 %arg20, ptr addrspace(1) poison876 store volatile i32 %arg21, ptr addrspace(1) poison877 store volatile i32 %arg22, ptr addrspace(1) poison878 store volatile i32 %arg23, ptr addrspace(1) poison879 880 store volatile i32 %arg24, ptr addrspace(1) poison881 store volatile i32 %arg25, ptr addrspace(1) poison882 store volatile i32 %arg26, ptr addrspace(1) poison883 store volatile i32 %arg27, ptr addrspace(1) poison884 store volatile i32 %arg28, ptr addrspace(1) poison885 store volatile i32 %arg29, ptr addrspace(1) poison886 store volatile i32 %arg30, ptr addrspace(1) poison887 store volatile i32 %arg31, ptr addrspace(1) poison888 %private = load volatile i32, ptr addrspace(5) %arg32889 ret void890}891 892; var abi stack layout:893; sp[0] = byval894; sp[1] = ??895; sp[2] = stack passed workitem ID x896define amdgpu_kernel void @kern_call_too_many_args_use_workitem_id_x_byval() #1 {897; GCN-LABEL: kern_call_too_many_args_use_workitem_id_x_byval:898; GCN: ; %bb.0:899; GCN-NEXT: s_add_u32 s0, s0, s5900; GCN-NEXT: s_addc_u32 s1, s1, 0901; GCN-NEXT: v_mov_b32_e32 v31, v0902; GCN-NEXT: v_mov_b32_e32 v0, 0x3e7903; GCN-NEXT: s_movk_i32 s32, 0x400904; GCN-NEXT: buffer_store_dword v0, off, s[0:3], 0905; GCN-NEXT: s_waitcnt vmcnt(0)906; GCN-NEXT: v_mov_b32_e32 v0, 0x140907; GCN-NEXT: buffer_store_dword v0, off, s[0:3], s32908; GCN-NEXT: buffer_load_dword v0, off, s[0:3], 0909; GCN-NEXT: s_getpc_b64 s[4:5]910; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_x_byval@gotpcrel32@lo+4911; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_x_byval@gotpcrel32@hi+12912; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0913; GCN-NEXT: v_mov_b32_e32 v1, 20914; GCN-NEXT: v_mov_b32_e32 v2, 30915; GCN-NEXT: v_mov_b32_e32 v3, 40916; GCN-NEXT: v_mov_b32_e32 v4, 50917; GCN-NEXT: v_mov_b32_e32 v5, 60918; GCN-NEXT: v_mov_b32_e32 v6, 0x46919; GCN-NEXT: v_mov_b32_e32 v7, 0x50920; GCN-NEXT: v_mov_b32_e32 v8, 0x5a921; GCN-NEXT: v_mov_b32_e32 v9, 0x64922; GCN-NEXT: v_mov_b32_e32 v10, 0x6e923; GCN-NEXT: v_mov_b32_e32 v11, 0x78924; GCN-NEXT: v_mov_b32_e32 v12, 0x82925; GCN-NEXT: v_mov_b32_e32 v13, 0x8c926; GCN-NEXT: v_mov_b32_e32 v14, 0x96927; GCN-NEXT: v_mov_b32_e32 v15, 0xa0928; GCN-NEXT: v_mov_b32_e32 v16, 0xaa929; GCN-NEXT: v_mov_b32_e32 v17, 0xb4930; GCN-NEXT: v_mov_b32_e32 v18, 0xbe931; GCN-NEXT: v_mov_b32_e32 v19, 0xc8932; GCN-NEXT: v_mov_b32_e32 v20, 0xd2933; GCN-NEXT: v_mov_b32_e32 v21, 0xdc934; GCN-NEXT: v_mov_b32_e32 v22, 0xe6935; GCN-NEXT: v_mov_b32_e32 v23, 0xf0936; GCN-NEXT: v_mov_b32_e32 v24, 0xfa937; GCN-NEXT: v_mov_b32_e32 v25, 0x104938; GCN-NEXT: v_mov_b32_e32 v26, 0x10e939; GCN-NEXT: v_mov_b32_e32 v27, 0x118940; GCN-NEXT: v_mov_b32_e32 v28, 0x122941; GCN-NEXT: v_mov_b32_e32 v29, 0x12c942; GCN-NEXT: v_mov_b32_e32 v30, 0x136943; GCN-NEXT: s_waitcnt vmcnt(0)944; GCN-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:4945; GCN-NEXT: v_mov_b32_e32 v0, 10946; GCN-NEXT: s_waitcnt lgkmcnt(0)947; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]948; GCN-NEXT: s_endpgm949 %alloca = alloca i32, align 4, addrspace(5)950 store volatile i32 999, ptr addrspace(5) %alloca951 call void @too_many_args_use_workitem_id_x_byval(952 i32 10, i32 20, i32 30, i32 40,953 i32 50, i32 60, i32 70, i32 80,954 i32 90, i32 100, i32 110, i32 120,955 i32 130, i32 140, i32 150, i32 160,956 i32 170, i32 180, i32 190, i32 200,957 i32 210, i32 220, i32 230, i32 240,958 i32 250, i32 260, i32 270, i32 280,959 i32 290, i32 300, i32 310, i32 320,960 ptr addrspace(5) byval(i32) %alloca)961 ret void962}963 964define void @func_call_too_many_args_use_workitem_id_x_byval() #1 {965; GCN-LABEL: func_call_too_many_args_use_workitem_id_x_byval:966; GCN: ; %bb.0:967; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)968; GCN-NEXT: s_mov_b32 s4, s33969; GCN-NEXT: s_mov_b32 s33, s32970; GCN-NEXT: s_or_saveexec_b64 s[6:7], -1971; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill972; GCN-NEXT: s_mov_b64 exec, s[6:7]973; GCN-NEXT: v_mov_b32_e32 v0, 0x3e7974; GCN-NEXT: s_addk_i32 s32, 0x400975; GCN-NEXT: buffer_store_dword v0, off, s[0:3], s33976; GCN-NEXT: s_waitcnt vmcnt(0)977; GCN-NEXT: v_mov_b32_e32 v0, 0x140978; GCN-NEXT: buffer_store_dword v0, off, s[0:3], s32979; GCN-NEXT: buffer_load_dword v0, off, s[0:3], s33980; GCN-NEXT: v_writelane_b32 v40, s4, 2981; GCN-NEXT: s_getpc_b64 s[4:5]982; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_x_byval@gotpcrel32@lo+4983; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_x_byval@gotpcrel32@hi+12984; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0985; GCN-NEXT: v_writelane_b32 v40, s30, 0986; GCN-NEXT: v_mov_b32_e32 v1, 20987; GCN-NEXT: v_mov_b32_e32 v2, 30988; GCN-NEXT: v_mov_b32_e32 v3, 40989; GCN-NEXT: v_mov_b32_e32 v4, 50990; GCN-NEXT: v_mov_b32_e32 v5, 60991; GCN-NEXT: v_mov_b32_e32 v6, 0x46992; GCN-NEXT: v_mov_b32_e32 v7, 0x50993; GCN-NEXT: v_mov_b32_e32 v8, 0x5a994; GCN-NEXT: v_mov_b32_e32 v9, 0x64995; GCN-NEXT: v_mov_b32_e32 v10, 0x6e996; GCN-NEXT: v_mov_b32_e32 v11, 0x78997; GCN-NEXT: v_mov_b32_e32 v12, 0x82998; GCN-NEXT: v_mov_b32_e32 v13, 0x8c999; GCN-NEXT: v_mov_b32_e32 v14, 0x961000; GCN-NEXT: v_mov_b32_e32 v15, 0xa01001; GCN-NEXT: v_mov_b32_e32 v16, 0xaa1002; GCN-NEXT: v_mov_b32_e32 v17, 0xb41003; GCN-NEXT: v_mov_b32_e32 v18, 0xbe1004; GCN-NEXT: v_mov_b32_e32 v19, 0xc81005; GCN-NEXT: v_mov_b32_e32 v20, 0xd21006; GCN-NEXT: v_mov_b32_e32 v21, 0xdc1007; GCN-NEXT: v_mov_b32_e32 v22, 0xe61008; GCN-NEXT: v_mov_b32_e32 v23, 0xf01009; GCN-NEXT: v_mov_b32_e32 v24, 0xfa1010; GCN-NEXT: v_mov_b32_e32 v25, 0x1041011; GCN-NEXT: v_mov_b32_e32 v26, 0x10e1012; GCN-NEXT: v_mov_b32_e32 v27, 0x1181013; GCN-NEXT: v_mov_b32_e32 v28, 0x1221014; GCN-NEXT: v_mov_b32_e32 v29, 0x12c1015; GCN-NEXT: v_mov_b32_e32 v30, 0x1361016; GCN-NEXT: v_writelane_b32 v40, s31, 11017; GCN-NEXT: s_waitcnt vmcnt(0)1018; GCN-NEXT: buffer_store_dword v0, off, s[0:3], s32 offset:41019; GCN-NEXT: v_mov_b32_e32 v0, 101020; GCN-NEXT: s_waitcnt lgkmcnt(0)1021; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]1022; GCN-NEXT: v_readlane_b32 s31, v40, 11023; GCN-NEXT: v_readlane_b32 s30, v40, 01024; GCN-NEXT: s_mov_b32 s32, s331025; GCN-NEXT: v_readlane_b32 s4, v40, 21026; GCN-NEXT: s_or_saveexec_b64 s[6:7], -11027; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload1028; GCN-NEXT: s_mov_b64 exec, s[6:7]1029; GCN-NEXT: s_mov_b32 s33, s41030; GCN-NEXT: s_waitcnt vmcnt(0)1031; GCN-NEXT: s_setpc_b64 s[30:31]1032 %alloca = alloca i32, align 4, addrspace(5)1033 store volatile i32 999, ptr addrspace(5) %alloca1034 call void @too_many_args_use_workitem_id_x_byval(1035 i32 10, i32 20, i32 30, i32 40,1036 i32 50, i32 60, i32 70, i32 80,1037 i32 90, i32 100, i32 110, i32 120,1038 i32 130, i32 140, i32 150, i32 160,1039 i32 170, i32 180, i32 190, i32 200,1040 i32 210, i32 220, i32 230, i32 240,1041 i32 250, i32 260, i32 270, i32 280,1042 i32 290, i32 300, i32 310, i32 320,1043 ptr addrspace(5) byval(i32) %alloca)1044 ret void1045}1046 1047define void @too_many_args_use_workitem_id_xyz(1048; GCN-LABEL: too_many_args_use_workitem_id_xyz:1049; GCN: ; %bb.0:1050; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1051; GCN-NEXT: v_and_b32_e32 v32, 0x3ff, v311052; GCN-NEXT: flat_store_dword v[0:1], v321053; GCN-NEXT: s_waitcnt vmcnt(0)1054; GCN-NEXT: v_bfe_u32 v32, v31, 10, 101055; GCN-NEXT: v_bfe_u32 v31, v31, 20, 101056; GCN-NEXT: flat_store_dword v[0:1], v321057; GCN-NEXT: s_waitcnt vmcnt(0)1058; GCN-NEXT: flat_store_dword v[0:1], v311059; GCN-NEXT: s_waitcnt vmcnt(0)1060; GCN-NEXT: buffer_load_dword v31, off, s[0:3], s321061; GCN-NEXT: flat_store_dword v[0:1], v01062; GCN-NEXT: s_waitcnt vmcnt(0)1063; GCN-NEXT: flat_store_dword v[0:1], v11064; GCN-NEXT: s_waitcnt vmcnt(0)1065; GCN-NEXT: flat_store_dword v[0:1], v21066; GCN-NEXT: s_waitcnt vmcnt(0)1067; GCN-NEXT: flat_store_dword v[0:1], v31068; GCN-NEXT: s_waitcnt vmcnt(0)1069; GCN-NEXT: flat_store_dword v[0:1], v41070; GCN-NEXT: s_waitcnt vmcnt(0)1071; GCN-NEXT: flat_store_dword v[0:1], v51072; GCN-NEXT: s_waitcnt vmcnt(0)1073; GCN-NEXT: flat_store_dword v[0:1], v61074; GCN-NEXT: s_waitcnt vmcnt(0)1075; GCN-NEXT: flat_store_dword v[0:1], v71076; GCN-NEXT: s_waitcnt vmcnt(0)1077; GCN-NEXT: flat_store_dword v[0:1], v81078; GCN-NEXT: s_waitcnt vmcnt(0)1079; GCN-NEXT: flat_store_dword v[0:1], v91080; GCN-NEXT: s_waitcnt vmcnt(0)1081; GCN-NEXT: flat_store_dword v[0:1], v101082; GCN-NEXT: s_waitcnt vmcnt(0)1083; GCN-NEXT: flat_store_dword v[0:1], v111084; GCN-NEXT: s_waitcnt vmcnt(0)1085; GCN-NEXT: flat_store_dword v[0:1], v121086; GCN-NEXT: s_waitcnt vmcnt(0)1087; GCN-NEXT: flat_store_dword v[0:1], v131088; GCN-NEXT: s_waitcnt vmcnt(0)1089; GCN-NEXT: flat_store_dword v[0:1], v141090; GCN-NEXT: s_waitcnt vmcnt(0)1091; GCN-NEXT: flat_store_dword v[0:1], v151092; GCN-NEXT: s_waitcnt vmcnt(0)1093; GCN-NEXT: flat_store_dword v[0:1], v161094; GCN-NEXT: s_waitcnt vmcnt(0)1095; GCN-NEXT: flat_store_dword v[0:1], v171096; GCN-NEXT: s_waitcnt vmcnt(0)1097; GCN-NEXT: flat_store_dword v[0:1], v181098; GCN-NEXT: s_waitcnt vmcnt(0)1099; GCN-NEXT: flat_store_dword v[0:1], v191100; GCN-NEXT: s_waitcnt vmcnt(0)1101; GCN-NEXT: flat_store_dword v[0:1], v201102; GCN-NEXT: s_waitcnt vmcnt(0)1103; GCN-NEXT: flat_store_dword v[0:1], v211104; GCN-NEXT: s_waitcnt vmcnt(0)1105; GCN-NEXT: flat_store_dword v[0:1], v221106; GCN-NEXT: s_waitcnt vmcnt(0)1107; GCN-NEXT: flat_store_dword v[0:1], v231108; GCN-NEXT: s_waitcnt vmcnt(0)1109; GCN-NEXT: flat_store_dword v[0:1], v241110; GCN-NEXT: s_waitcnt vmcnt(0)1111; GCN-NEXT: flat_store_dword v[0:1], v251112; GCN-NEXT: s_waitcnt vmcnt(0)1113; GCN-NEXT: flat_store_dword v[0:1], v261114; GCN-NEXT: s_waitcnt vmcnt(0)1115; GCN-NEXT: flat_store_dword v[0:1], v271116; GCN-NEXT: s_waitcnt vmcnt(0)1117; GCN-NEXT: flat_store_dword v[0:1], v281118; GCN-NEXT: s_waitcnt vmcnt(0)1119; GCN-NEXT: flat_store_dword v[0:1], v291120; GCN-NEXT: s_waitcnt vmcnt(0)1121; GCN-NEXT: flat_store_dword v[0:1], v301122; GCN-NEXT: s_waitcnt vmcnt(0)1123; GCN-NEXT: flat_store_dword v[0:1], v311124; GCN-NEXT: s_waitcnt vmcnt(0)1125; GCN-NEXT: s_setpc_b64 s[30:31]1126 i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7,1127 i32 %arg8, i32 %arg9, i32 %arg10, i32 %arg11, i32 %arg12, i32 %arg13, i32 %arg14, i32 %arg15,1128 i32 %arg16, i32 %arg17, i32 %arg18, i32 %arg19, i32 %arg20, i32 %arg21, i32 %arg22, i32 %arg23,1129 i32 %arg24, i32 %arg25, i32 %arg26, i32 %arg27, i32 %arg28, i32 %arg29, i32 %arg30, i32 %arg31) #1 {1130 %val0 = call i32 @llvm.amdgcn.workitem.id.x()1131 store volatile i32 %val0, ptr addrspace(1) poison1132 %val1 = call i32 @llvm.amdgcn.workitem.id.y()1133 store volatile i32 %val1, ptr addrspace(1) poison1134 %val2 = call i32 @llvm.amdgcn.workitem.id.z()1135 store volatile i32 %val2, ptr addrspace(1) poison1136 1137 store volatile i32 %arg0, ptr addrspace(1) poison1138 store volatile i32 %arg1, ptr addrspace(1) poison1139 store volatile i32 %arg2, ptr addrspace(1) poison1140 store volatile i32 %arg3, ptr addrspace(1) poison1141 store volatile i32 %arg4, ptr addrspace(1) poison1142 store volatile i32 %arg5, ptr addrspace(1) poison1143 store volatile i32 %arg6, ptr addrspace(1) poison1144 store volatile i32 %arg7, ptr addrspace(1) poison1145 1146 store volatile i32 %arg8, ptr addrspace(1) poison1147 store volatile i32 %arg9, ptr addrspace(1) poison1148 store volatile i32 %arg10, ptr addrspace(1) poison1149 store volatile i32 %arg11, ptr addrspace(1) poison1150 store volatile i32 %arg12, ptr addrspace(1) poison1151 store volatile i32 %arg13, ptr addrspace(1) poison1152 store volatile i32 %arg14, ptr addrspace(1) poison1153 store volatile i32 %arg15, ptr addrspace(1) poison1154 1155 store volatile i32 %arg16, ptr addrspace(1) poison1156 store volatile i32 %arg17, ptr addrspace(1) poison1157 store volatile i32 %arg18, ptr addrspace(1) poison1158 store volatile i32 %arg19, ptr addrspace(1) poison1159 store volatile i32 %arg20, ptr addrspace(1) poison1160 store volatile i32 %arg21, ptr addrspace(1) poison1161 store volatile i32 %arg22, ptr addrspace(1) poison1162 store volatile i32 %arg23, ptr addrspace(1) poison1163 1164 store volatile i32 %arg24, ptr addrspace(1) poison1165 store volatile i32 %arg25, ptr addrspace(1) poison1166 store volatile i32 %arg26, ptr addrspace(1) poison1167 store volatile i32 %arg27, ptr addrspace(1) poison1168 store volatile i32 %arg28, ptr addrspace(1) poison1169 store volatile i32 %arg29, ptr addrspace(1) poison1170 store volatile i32 %arg30, ptr addrspace(1) poison1171 store volatile i32 %arg31, ptr addrspace(1) poison1172 1173 ret void1174}1175 1176define amdgpu_kernel void @kern_call_too_many_args_use_workitem_id_xyz() #1 {1177; GCN-LABEL: kern_call_too_many_args_use_workitem_id_xyz:1178; GCN: ; %bb.0:1179; GCN-NEXT: s_add_u32 s0, s0, s51180; GCN-NEXT: s_addc_u32 s1, s1, 01181; GCN-NEXT: s_getpc_b64 s[4:5]1182; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_xyz@gotpcrel32@lo+41183; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_xyz@gotpcrel32@hi+121184; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x01185; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v11186; GCN-NEXT: s_mov_b32 s32, 01187; GCN-NEXT: v_mov_b32_e32 v3, 0x1401188; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v21189; GCN-NEXT: v_or_b32_e32 v0, v0, v11190; GCN-NEXT: buffer_store_dword v3, off, s[0:3], s321191; GCN-NEXT: v_or_b32_e32 v31, v0, v21192; GCN-NEXT: v_mov_b32_e32 v0, 101193; GCN-NEXT: v_mov_b32_e32 v1, 201194; GCN-NEXT: v_mov_b32_e32 v2, 301195; GCN-NEXT: v_mov_b32_e32 v3, 401196; GCN-NEXT: v_mov_b32_e32 v4, 501197; GCN-NEXT: v_mov_b32_e32 v5, 601198; GCN-NEXT: v_mov_b32_e32 v6, 0x461199; GCN-NEXT: v_mov_b32_e32 v7, 0x501200; GCN-NEXT: v_mov_b32_e32 v8, 0x5a1201; GCN-NEXT: v_mov_b32_e32 v9, 0x641202; GCN-NEXT: v_mov_b32_e32 v10, 0x6e1203; GCN-NEXT: v_mov_b32_e32 v11, 0x781204; GCN-NEXT: v_mov_b32_e32 v12, 0x821205; GCN-NEXT: v_mov_b32_e32 v13, 0x8c1206; GCN-NEXT: v_mov_b32_e32 v14, 0x961207; GCN-NEXT: v_mov_b32_e32 v15, 0xa01208; GCN-NEXT: v_mov_b32_e32 v16, 0xaa1209; GCN-NEXT: v_mov_b32_e32 v17, 0xb41210; GCN-NEXT: v_mov_b32_e32 v18, 0xbe1211; GCN-NEXT: v_mov_b32_e32 v19, 0xc81212; GCN-NEXT: v_mov_b32_e32 v20, 0xd21213; GCN-NEXT: v_mov_b32_e32 v21, 0xdc1214; GCN-NEXT: v_mov_b32_e32 v22, 0xe61215; GCN-NEXT: v_mov_b32_e32 v23, 0xf01216; GCN-NEXT: v_mov_b32_e32 v24, 0xfa1217; GCN-NEXT: v_mov_b32_e32 v25, 0x1041218; GCN-NEXT: v_mov_b32_e32 v26, 0x10e1219; GCN-NEXT: v_mov_b32_e32 v27, 0x1181220; GCN-NEXT: v_mov_b32_e32 v28, 0x1221221; GCN-NEXT: v_mov_b32_e32 v29, 0x12c1222; GCN-NEXT: v_mov_b32_e32 v30, 0x1361223; GCN-NEXT: s_waitcnt lgkmcnt(0)1224; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]1225; GCN-NEXT: s_endpgm1226 call void @too_many_args_use_workitem_id_xyz(1227 i32 10, i32 20, i32 30, i32 40,1228 i32 50, i32 60, i32 70, i32 80,1229 i32 90, i32 100, i32 110, i32 120,1230 i32 130, i32 140, i32 150, i32 160,1231 i32 170, i32 180, i32 190, i32 200,1232 i32 210, i32 220, i32 230, i32 240,1233 i32 250, i32 260, i32 270, i32 280,1234 i32 290, i32 300, i32 310, i32 320)1235 ret void1236}1237; GCN: .amdhsa_system_vgpr_workitem_id 21238 1239; Var abi: workitem ID X in register, yz on stack1240; v31 = workitem ID X1241; frame[0] = workitem { Z, Y, X }1242define void @too_many_args_use_workitem_id_x_stack_yz(1243; GCN-LABEL: too_many_args_use_workitem_id_x_stack_yz:1244; GCN: ; %bb.0:1245; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1246; GCN-NEXT: v_and_b32_e32 v32, 0x3ff, v311247; GCN-NEXT: flat_store_dword v[0:1], v321248; GCN-NEXT: s_waitcnt vmcnt(0)1249; GCN-NEXT: v_bfe_u32 v32, v31, 10, 101250; GCN-NEXT: v_bfe_u32 v31, v31, 20, 101251; GCN-NEXT: flat_store_dword v[0:1], v321252; GCN-NEXT: s_waitcnt vmcnt(0)1253; GCN-NEXT: flat_store_dword v[0:1], v311254; GCN-NEXT: s_waitcnt vmcnt(0)1255; GCN-NEXT: flat_store_dword v[0:1], v01256; GCN-NEXT: s_waitcnt vmcnt(0)1257; GCN-NEXT: flat_store_dword v[0:1], v11258; GCN-NEXT: s_waitcnt vmcnt(0)1259; GCN-NEXT: flat_store_dword v[0:1], v21260; GCN-NEXT: s_waitcnt vmcnt(0)1261; GCN-NEXT: flat_store_dword v[0:1], v31262; GCN-NEXT: s_waitcnt vmcnt(0)1263; GCN-NEXT: flat_store_dword v[0:1], v41264; GCN-NEXT: s_waitcnt vmcnt(0)1265; GCN-NEXT: flat_store_dword v[0:1], v51266; GCN-NEXT: s_waitcnt vmcnt(0)1267; GCN-NEXT: flat_store_dword v[0:1], v61268; GCN-NEXT: s_waitcnt vmcnt(0)1269; GCN-NEXT: flat_store_dword v[0:1], v71270; GCN-NEXT: s_waitcnt vmcnt(0)1271; GCN-NEXT: flat_store_dword v[0:1], v81272; GCN-NEXT: s_waitcnt vmcnt(0)1273; GCN-NEXT: flat_store_dword v[0:1], v91274; GCN-NEXT: s_waitcnt vmcnt(0)1275; GCN-NEXT: flat_store_dword v[0:1], v101276; GCN-NEXT: s_waitcnt vmcnt(0)1277; GCN-NEXT: flat_store_dword v[0:1], v111278; GCN-NEXT: s_waitcnt vmcnt(0)1279; GCN-NEXT: flat_store_dword v[0:1], v121280; GCN-NEXT: s_waitcnt vmcnt(0)1281; GCN-NEXT: flat_store_dword v[0:1], v131282; GCN-NEXT: s_waitcnt vmcnt(0)1283; GCN-NEXT: flat_store_dword v[0:1], v141284; GCN-NEXT: s_waitcnt vmcnt(0)1285; GCN-NEXT: flat_store_dword v[0:1], v151286; GCN-NEXT: s_waitcnt vmcnt(0)1287; GCN-NEXT: flat_store_dword v[0:1], v161288; GCN-NEXT: s_waitcnt vmcnt(0)1289; GCN-NEXT: flat_store_dword v[0:1], v171290; GCN-NEXT: s_waitcnt vmcnt(0)1291; GCN-NEXT: flat_store_dword v[0:1], v181292; GCN-NEXT: s_waitcnt vmcnt(0)1293; GCN-NEXT: flat_store_dword v[0:1], v191294; GCN-NEXT: s_waitcnt vmcnt(0)1295; GCN-NEXT: flat_store_dword v[0:1], v201296; GCN-NEXT: s_waitcnt vmcnt(0)1297; GCN-NEXT: flat_store_dword v[0:1], v211298; GCN-NEXT: s_waitcnt vmcnt(0)1299; GCN-NEXT: flat_store_dword v[0:1], v221300; GCN-NEXT: s_waitcnt vmcnt(0)1301; GCN-NEXT: flat_store_dword v[0:1], v231302; GCN-NEXT: s_waitcnt vmcnt(0)1303; GCN-NEXT: flat_store_dword v[0:1], v241304; GCN-NEXT: s_waitcnt vmcnt(0)1305; GCN-NEXT: flat_store_dword v[0:1], v251306; GCN-NEXT: s_waitcnt vmcnt(0)1307; GCN-NEXT: flat_store_dword v[0:1], v261308; GCN-NEXT: s_waitcnt vmcnt(0)1309; GCN-NEXT: flat_store_dword v[0:1], v271310; GCN-NEXT: s_waitcnt vmcnt(0)1311; GCN-NEXT: flat_store_dword v[0:1], v281312; GCN-NEXT: s_waitcnt vmcnt(0)1313; GCN-NEXT: flat_store_dword v[0:1], v291314; GCN-NEXT: s_waitcnt vmcnt(0)1315; GCN-NEXT: flat_store_dword v[0:1], v301316; GCN-NEXT: s_waitcnt vmcnt(0)1317; GCN-NEXT: s_setpc_b64 s[30:31]1318 i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7,1319 i32 %arg8, i32 %arg9, i32 %arg10, i32 %arg11, i32 %arg12, i32 %arg13, i32 %arg14, i32 %arg15,1320 i32 %arg16, i32 %arg17, i32 %arg18, i32 %arg19, i32 %arg20, i32 %arg21, i32 %arg22, i32 %arg23,1321 i32 %arg24, i32 %arg25, i32 %arg26, i32 %arg27, i32 %arg28, i32 %arg29, i32 %arg30) #1 {1322 %val0 = call i32 @llvm.amdgcn.workitem.id.x()1323 store volatile i32 %val0, ptr addrspace(1) poison1324 %val1 = call i32 @llvm.amdgcn.workitem.id.y()1325 store volatile i32 %val1, ptr addrspace(1) poison1326 %val2 = call i32 @llvm.amdgcn.workitem.id.z()1327 store volatile i32 %val2, ptr addrspace(1) poison1328 1329 store volatile i32 %arg0, ptr addrspace(1) poison1330 store volatile i32 %arg1, ptr addrspace(1) poison1331 store volatile i32 %arg2, ptr addrspace(1) poison1332 store volatile i32 %arg3, ptr addrspace(1) poison1333 store volatile i32 %arg4, ptr addrspace(1) poison1334 store volatile i32 %arg5, ptr addrspace(1) poison1335 store volatile i32 %arg6, ptr addrspace(1) poison1336 store volatile i32 %arg7, ptr addrspace(1) poison1337 1338 store volatile i32 %arg8, ptr addrspace(1) poison1339 store volatile i32 %arg9, ptr addrspace(1) poison1340 store volatile i32 %arg10, ptr addrspace(1) poison1341 store volatile i32 %arg11, ptr addrspace(1) poison1342 store volatile i32 %arg12, ptr addrspace(1) poison1343 store volatile i32 %arg13, ptr addrspace(1) poison1344 store volatile i32 %arg14, ptr addrspace(1) poison1345 store volatile i32 %arg15, ptr addrspace(1) poison1346 1347 store volatile i32 %arg16, ptr addrspace(1) poison1348 store volatile i32 %arg17, ptr addrspace(1) poison1349 store volatile i32 %arg18, ptr addrspace(1) poison1350 store volatile i32 %arg19, ptr addrspace(1) poison1351 store volatile i32 %arg20, ptr addrspace(1) poison1352 store volatile i32 %arg21, ptr addrspace(1) poison1353 store volatile i32 %arg22, ptr addrspace(1) poison1354 store volatile i32 %arg23, ptr addrspace(1) poison1355 1356 store volatile i32 %arg24, ptr addrspace(1) poison1357 store volatile i32 %arg25, ptr addrspace(1) poison1358 store volatile i32 %arg26, ptr addrspace(1) poison1359 store volatile i32 %arg27, ptr addrspace(1) poison1360 store volatile i32 %arg28, ptr addrspace(1) poison1361 store volatile i32 %arg29, ptr addrspace(1) poison1362 store volatile i32 %arg30, ptr addrspace(1) poison1363 1364 ret void1365}1366; GCN: ScratchSize: 01367 1368define amdgpu_kernel void @kern_call_too_many_args_use_workitem_id_x_stack_yz() #1 {1369; GCN-LABEL: kern_call_too_many_args_use_workitem_id_x_stack_yz:1370; GCN: ; %bb.0:1371; GCN-NEXT: s_add_u32 s0, s0, s51372; GCN-NEXT: s_addc_u32 s1, s1, 01373; GCN-NEXT: s_getpc_b64 s[4:5]1374; GCN-NEXT: s_add_u32 s4, s4, too_many_args_use_workitem_id_x_stack_yz@gotpcrel32@lo+41375; GCN-NEXT: s_addc_u32 s5, s5, too_many_args_use_workitem_id_x_stack_yz@gotpcrel32@hi+121376; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x01377; GCN-NEXT: v_lshlrev_b32_e32 v1, 10, v11378; GCN-NEXT: v_lshlrev_b32_e32 v2, 20, v21379; GCN-NEXT: v_or_b32_e32 v0, v0, v11380; GCN-NEXT: v_or_b32_e32 v31, v0, v21381; GCN-NEXT: v_mov_b32_e32 v0, 101382; GCN-NEXT: v_mov_b32_e32 v1, 201383; GCN-NEXT: v_mov_b32_e32 v2, 301384; GCN-NEXT: v_mov_b32_e32 v3, 401385; GCN-NEXT: v_mov_b32_e32 v4, 501386; GCN-NEXT: v_mov_b32_e32 v5, 601387; GCN-NEXT: v_mov_b32_e32 v6, 0x461388; GCN-NEXT: v_mov_b32_e32 v7, 0x501389; GCN-NEXT: v_mov_b32_e32 v8, 0x5a1390; GCN-NEXT: v_mov_b32_e32 v9, 0x641391; GCN-NEXT: v_mov_b32_e32 v10, 0x6e1392; GCN-NEXT: v_mov_b32_e32 v11, 0x781393; GCN-NEXT: v_mov_b32_e32 v12, 0x821394; GCN-NEXT: v_mov_b32_e32 v13, 0x8c1395; GCN-NEXT: v_mov_b32_e32 v14, 0x961396; GCN-NEXT: v_mov_b32_e32 v15, 0xa01397; GCN-NEXT: v_mov_b32_e32 v16, 0xaa1398; GCN-NEXT: v_mov_b32_e32 v17, 0xb41399; GCN-NEXT: v_mov_b32_e32 v18, 0xbe1400; GCN-NEXT: v_mov_b32_e32 v19, 0xc81401; GCN-NEXT: v_mov_b32_e32 v20, 0xd21402; GCN-NEXT: v_mov_b32_e32 v21, 0xdc1403; GCN-NEXT: v_mov_b32_e32 v22, 0xe61404; GCN-NEXT: v_mov_b32_e32 v23, 0xf01405; GCN-NEXT: v_mov_b32_e32 v24, 0xfa1406; GCN-NEXT: v_mov_b32_e32 v25, 0x1041407; GCN-NEXT: v_mov_b32_e32 v26, 0x10e1408; GCN-NEXT: v_mov_b32_e32 v27, 0x1181409; GCN-NEXT: v_mov_b32_e32 v28, 0x1221410; GCN-NEXT: v_mov_b32_e32 v29, 0x12c1411; GCN-NEXT: v_mov_b32_e32 v30, 0x1361412; GCN-NEXT: s_mov_b32 s32, 01413; GCN-NEXT: s_waitcnt lgkmcnt(0)1414; GCN-NEXT: s_swappc_b64 s[30:31], s[4:5]1415; GCN-NEXT: s_endpgm1416 call void @too_many_args_use_workitem_id_x_stack_yz(1417 i32 10, i32 20, i32 30, i32 40,1418 i32 50, i32 60, i32 70, i32 80,1419 i32 90, i32 100, i32 110, i32 120,1420 i32 130, i32 140, i32 150, i32 160,1421 i32 170, i32 180, i32 190, i32 200,1422 i32 210, i32 220, i32 230, i32 240,1423 i32 250, i32 260, i32 270, i32 280,1424 i32 290, i32 300, i32 310)1425 ret void1426}1427; GCN: .amdhsa_system_vgpr_workitem_id 21428 1429declare hidden void @extern_hint(i32) #21430 1431; Workitem IDs should not be passed due to the attribute1432define amdgpu_kernel void @kern_call_no_workitem_id_hints() #2 {1433; GCN-LABEL: kern_call_no_workitem_id_hints:1434; GCN: ; %bb.0:1435; GCN-NEXT: s_add_i32 s12, s12, s171436; GCN-NEXT: s_lshr_b32 flat_scratch_hi, s12, 81437; GCN-NEXT: s_add_u32 s0, s0, s171438; GCN-NEXT: s_addc_u32 s1, s1, 01439; GCN-NEXT: s_mov_b32 flat_scratch_lo, s131440; GCN-NEXT: s_mov_b32 s13, s151441; GCN-NEXT: s_mov_b32 s12, s141442; GCN-NEXT: s_getpc_b64 s[18:19]1443; GCN-NEXT: s_add_u32 s18, s18, extern_hint@rel32@lo+41444; GCN-NEXT: s_addc_u32 s19, s19, extern_hint@rel32@hi+121445; GCN-NEXT: s_mov_b32 s14, s161446; GCN-NEXT: v_mov_b32_e32 v0, 91447; GCN-NEXT: s_mov_b32 s32, 01448; GCN-NEXT: s_swappc_b64 s[30:31], s[18:19]1449; GCN-NEXT: s_endpgm1450 call void @extern_hint(i32 9)1451 ret void1452}1453 1454define void @func_call_no_workitem_id_hints() #2 {1455; GCN-LABEL: func_call_no_workitem_id_hints:1456; GCN: ; %bb.0:1457; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)1458; GCN-NEXT: s_mov_b32 s16, s331459; GCN-NEXT: s_mov_b32 s33, s321460; GCN-NEXT: s_or_saveexec_b64 s[18:19], -11461; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill1462; GCN-NEXT: s_mov_b64 exec, s[18:19]1463; GCN-NEXT: v_writelane_b32 v40, s16, 21464; GCN-NEXT: s_addk_i32 s32, 0x4001465; GCN-NEXT: v_writelane_b32 v40, s30, 01466; GCN-NEXT: s_getpc_b64 s[16:17]1467; GCN-NEXT: s_add_u32 s16, s16, extern_hint@rel32@lo+41468; GCN-NEXT: s_addc_u32 s17, s17, extern_hint@rel32@hi+121469; GCN-NEXT: v_mov_b32_e32 v0, 91470; GCN-NEXT: v_writelane_b32 v40, s31, 11471; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]1472; GCN-NEXT: v_readlane_b32 s31, v40, 11473; GCN-NEXT: v_readlane_b32 s30, v40, 01474; GCN-NEXT: s_mov_b32 s32, s331475; GCN-NEXT: v_readlane_b32 s4, v40, 21476; GCN-NEXT: s_or_saveexec_b64 s[6:7], -11477; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload1478; GCN-NEXT: s_mov_b64 exec, s[6:7]1479; GCN-NEXT: s_mov_b32 s33, s41480; GCN-NEXT: s_waitcnt vmcnt(0)1481; GCN-NEXT: s_setpc_b64 s[30:31]1482 call void @extern_hint(i32 9)1483 ret void1484}1485 1486declare hidden void @extern_nohint(i32)1487 1488; Check that the hint is respected on the callsite, not the function1489; declaration1490define amdgpu_kernel void @kern_callsite_workitem_id_hints() #2 {1491; GCN-LABEL: kern_callsite_workitem_id_hints:1492; GCN: ; %bb.0:1493; GCN-NEXT: s_add_i32 s12, s12, s171494; GCN-NEXT: s_lshr_b32 flat_scratch_hi, s12, 81495; GCN-NEXT: s_add_u32 s0, s0, s171496; GCN-NEXT: s_addc_u32 s1, s1, 01497; GCN-NEXT: s_mov_b32 flat_scratch_lo, s131498; GCN-NEXT: s_mov_b32 s13, s151499; GCN-NEXT: s_mov_b32 s12, s141500; GCN-NEXT: s_getpc_b64 s[18:19]1501; GCN-NEXT: s_add_u32 s18, s18, extern_nohint@rel32@lo+41502; GCN-NEXT: s_addc_u32 s19, s19, extern_nohint@rel32@hi+121503; GCN-NEXT: s_mov_b32 s14, s161504; GCN-NEXT: v_mov_b32_e32 v0, 91505; GCN-NEXT: s_mov_b32 s32, 01506; GCN-NEXT: s_swappc_b64 s[30:31], s[18:19]1507; GCN-NEXT: s_endpgm1508 call void @extern_nohint(i32 9) #21509 ret void1510}1511 1512declare i32 @llvm.amdgcn.workitem.id.x() #01513declare i32 @llvm.amdgcn.workitem.id.y() #01514declare i32 @llvm.amdgcn.workitem.id.z() #01515 1516attributes #0 = { nounwind readnone speculatable }1517attributes #1 = { nounwind noinline }1518attributes #2 = { nounwind "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" }1519 1520!llvm.module.flags = !{!0}1521!0 = !{i32 1, !"amdhsa_code_object_version", i32 400}1522