233 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=amdgcn -mcpu=gfx900 < %s --amdgpu-lower-module-lds-strategy=module | FileCheck -enable-var-scope -check-prefixes=CHECK,GFX9 %s3; RUN: llc -mtriple=amdgcn -mcpu=gfx1010 < %s --amdgpu-lower-module-lds-strategy=module | FileCheck -enable-var-scope -check-prefixes=CHECK,GFX10 %s4; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx900 < %s --amdgpu-lower-module-lds-strategy=module | FileCheck -enable-var-scope -check-prefixes=CHECK,G_GFX9 %s5; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx1010 < %s --amdgpu-lower-module-lds-strategy=module | FileCheck -enable-var-scope -check-prefixes=CHECK,G_GFX10 %s6 7; Test case looks at the allocated offset of @used_by_both. It's at zero when8; allocated by itself, but at 8 when allocated in combination with the double.9; Redundantly also checks LDSByteSize.10@used_by_both = addrspace(3) global i32 poison11@used_by_kernel = addrspace(3) global i32 poison12@used_by_function = addrspace(3) global double poison13 14; kernel that calls no functions and uses an LDS variable allocates only that15; variable, so accesses at at offset 0 and LDSByteSize is 416define amdgpu_kernel void @nocall_ideal() {17; CHECK-LABEL: nocall_ideal:18; CHECK: ; %bb.0:19; CHECK-NEXT: v_mov_b32_e32 v0, 020; CHECK-NEXT: ds_write_b32 v0, v021; CHECK-NEXT: s_endpgm22store i32 0, ptr addrspace(3) @used_by_kernel23 ret void24}25; CHECK: ; LDSByteSize: 4 bytes26 27define void @nonkernel() {28; GFX9-LABEL: nonkernel:29; GFX9: ; %bb.0:30; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)31; GFX9-NEXT: v_mov_b32_e32 v0, 032; GFX9-NEXT: v_mov_b32_e32 v1, v033; GFX9-NEXT: ds_write_b32 v0, v0 offset:834; GFX9-NEXT: ds_write_b64 v0, v[0:1]35; GFX9-NEXT: s_waitcnt lgkmcnt(0)36; GFX9-NEXT: s_setpc_b64 s[30:31]37;38; GFX10-LABEL: nonkernel:39; GFX10: ; %bb.0:40; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)41; GFX10-NEXT: v_mov_b32_e32 v0, 042; GFX10-NEXT: v_mov_b32_e32 v1, v043; GFX10-NEXT: ds_write_b32 v0, v0 offset:844; GFX10-NEXT: ds_write_b64 v0, v[0:1]45; GFX10-NEXT: s_waitcnt lgkmcnt(0)46; GFX10-NEXT: s_setpc_b64 s[30:31]47;48; G_GFX9-LABEL: nonkernel:49; G_GFX9: ; %bb.0:50; G_GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)51; G_GFX9-NEXT: v_mov_b32_e32 v2, 052; G_GFX9-NEXT: v_mov_b32_e32 v3, 853; G_GFX9-NEXT: v_mov_b32_e32 v0, 054; G_GFX9-NEXT: v_mov_b32_e32 v1, 055; G_GFX9-NEXT: ds_write_b32 v3, v256; G_GFX9-NEXT: ds_write_b64 v2, v[0:1]57; G_GFX9-NEXT: s_waitcnt lgkmcnt(0)58; G_GFX9-NEXT: s_setpc_b64 s[30:31]59;60; G_GFX10-LABEL: nonkernel:61; G_GFX10: ; %bb.0:62; G_GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)63; G_GFX10-NEXT: v_mov_b32_e32 v2, 064; G_GFX10-NEXT: v_mov_b32_e32 v3, 865; G_GFX10-NEXT: v_mov_b32_e32 v0, 066; G_GFX10-NEXT: v_mov_b32_e32 v1, 067; G_GFX10-NEXT: ds_write_b32 v3, v268; G_GFX10-NEXT: ds_write_b64 v2, v[0:1]69; G_GFX10-NEXT: s_waitcnt lgkmcnt(0)70; G_GFX10-NEXT: s_setpc_b64 s[30:31]71 store i32 0, ptr addrspace(3) @used_by_both72 store double 0.0, ptr addrspace(3) @used_by_function73 ret void74}75 76; Needs to allocate both variables, store to used_by_both is at sizeof(double)77define amdgpu_kernel void @withcall() {78; GFX9-LABEL: withcall:79; GFX9: ; %bb.0:80; GFX9-NEXT: s_mov_b32 s20, SCRATCH_RSRC_DWORD081; GFX9-NEXT: s_mov_b32 s21, SCRATCH_RSRC_DWORD182; GFX9-NEXT: s_mov_b32 s22, -183; GFX9-NEXT: s_mov_b32 s23, 0xe0000084; GFX9-NEXT: s_add_u32 s20, s20, s1185; GFX9-NEXT: s_addc_u32 s21, s21, 086; GFX9-NEXT: s_mov_b32 s12, s887; GFX9-NEXT: s_add_u32 s8, s4, 3688; GFX9-NEXT: s_mov_b32 s13, s989; GFX9-NEXT: s_addc_u32 s9, s5, 090; GFX9-NEXT: s_getpc_b64 s[4:5]91; GFX9-NEXT: s_add_u32 s4, s4, nonkernel@gotpcrel32@lo+492; GFX9-NEXT: s_addc_u32 s5, s5, nonkernel@gotpcrel32@hi+1293; GFX9-NEXT: s_load_dwordx2 s[16:17], s[4:5], 0x094; GFX9-NEXT: s_mov_b32 s14, s1095; GFX9-NEXT: s_mov_b64 s[10:11], s[6:7]96; GFX9-NEXT: v_lshlrev_b32_e32 v2, 20, v297; GFX9-NEXT: v_lshlrev_b32_e32 v1, 10, v198; GFX9-NEXT: s_mov_b64 s[4:5], s[0:1]99; GFX9-NEXT: s_mov_b64 s[6:7], s[2:3]100; GFX9-NEXT: s_mov_b64 s[0:1], s[20:21]101; GFX9-NEXT: v_mov_b32_e32 v3, 0102; GFX9-NEXT: v_or3_b32 v31, v0, v1, v2103; GFX9-NEXT: s_mov_b64 s[2:3], s[22:23]104; GFX9-NEXT: s_mov_b32 s32, 0105; GFX9-NEXT: ds_write_b32 v3, v3 offset:8106; GFX9-NEXT: s_waitcnt lgkmcnt(0)107; GFX9-NEXT: s_swappc_b64 s[30:31], s[16:17]108; GFX9-NEXT: s_endpgm109;110; GFX10-LABEL: withcall:111; GFX10: ; %bb.0:112; GFX10-NEXT: s_mov_b32 s20, SCRATCH_RSRC_DWORD0113; GFX10-NEXT: s_mov_b32 s21, SCRATCH_RSRC_DWORD1114; GFX10-NEXT: s_mov_b32 s22, -1115; GFX10-NEXT: s_mov_b32 s23, 0x31c16000116; GFX10-NEXT: s_add_u32 s20, s20, s11117; GFX10-NEXT: s_addc_u32 s21, s21, 0118; GFX10-NEXT: s_mov_b32 s12, s8119; GFX10-NEXT: s_add_u32 s8, s4, 36120; GFX10-NEXT: s_mov_b32 s13, s9121; GFX10-NEXT: s_addc_u32 s9, s5, 0122; GFX10-NEXT: s_getpc_b64 s[4:5]123; GFX10-NEXT: s_add_u32 s4, s4, nonkernel@gotpcrel32@lo+4124; GFX10-NEXT: s_addc_u32 s5, s5, nonkernel@gotpcrel32@hi+12125; GFX10-NEXT: v_lshlrev_b32_e32 v2, 20, v2126; GFX10-NEXT: s_load_dwordx2 s[16:17], s[4:5], 0x0127; GFX10-NEXT: v_lshlrev_b32_e32 v1, 10, v1128; GFX10-NEXT: v_mov_b32_e32 v3, 0129; GFX10-NEXT: s_mov_b32 s14, s10130; GFX10-NEXT: s_mov_b64 s[10:11], s[6:7]131; GFX10-NEXT: s_mov_b64 s[4:5], s[0:1]132; GFX10-NEXT: v_or3_b32 v31, v0, v1, v2133; GFX10-NEXT: s_mov_b64 s[6:7], s[2:3]134; GFX10-NEXT: s_mov_b64 s[0:1], s[20:21]135; GFX10-NEXT: s_mov_b64 s[2:3], s[22:23]136; GFX10-NEXT: s_mov_b32 s32, 0137; GFX10-NEXT: ds_write_b32 v3, v3 offset:8138; GFX10-NEXT: s_waitcnt lgkmcnt(0)139; GFX10-NEXT: s_swappc_b64 s[30:31], s[16:17]140; GFX10-NEXT: s_endpgm141;142; G_GFX9-LABEL: withcall:143; G_GFX9: ; %bb.0:144; G_GFX9-NEXT: s_mov_b32 s20, SCRATCH_RSRC_DWORD0145; G_GFX9-NEXT: s_mov_b32 s21, SCRATCH_RSRC_DWORD1146; G_GFX9-NEXT: s_mov_b32 s22, -1147; G_GFX9-NEXT: s_mov_b32 s23, 0xe00000148; G_GFX9-NEXT: s_add_u32 s20, s20, s11149; G_GFX9-NEXT: s_addc_u32 s21, s21, 0150; G_GFX9-NEXT: s_mov_b32 s16, s8151; G_GFX9-NEXT: s_add_u32 s8, s4, 36152; G_GFX9-NEXT: s_mov_b32 s15, s9153; G_GFX9-NEXT: s_addc_u32 s9, s5, 0154; G_GFX9-NEXT: s_mov_b64 s[12:13], s[0:1]155; G_GFX9-NEXT: s_getpc_b64 s[0:1]156; G_GFX9-NEXT: s_add_u32 s0, s0, nonkernel@gotpcrel32@lo+4157; G_GFX9-NEXT: s_addc_u32 s1, s1, nonkernel@gotpcrel32@hi+12158; G_GFX9-NEXT: s_load_dwordx2 s[18:19], s[0:1], 0x0159; G_GFX9-NEXT: s_mov_b32 s14, s10160; G_GFX9-NEXT: s_mov_b64 s[10:11], s[6:7]161; G_GFX9-NEXT: s_mov_b64 s[6:7], s[2:3]162; G_GFX9-NEXT: v_lshlrev_b32_e32 v1, 10, v1163; G_GFX9-NEXT: v_lshlrev_b32_e32 v2, 20, v2164; G_GFX9-NEXT: s_mov_b64 s[0:1], s[20:21]165; G_GFX9-NEXT: v_mov_b32_e32 v3, 0166; G_GFX9-NEXT: v_mov_b32_e32 v4, 8167; G_GFX9-NEXT: v_or3_b32 v31, v0, v1, v2168; G_GFX9-NEXT: s_mov_b64 s[2:3], s[22:23]169; G_GFX9-NEXT: s_mov_b64 s[4:5], s[12:13]170; G_GFX9-NEXT: s_mov_b32 s12, s16171; G_GFX9-NEXT: s_mov_b32 s13, s15172; G_GFX9-NEXT: s_mov_b32 s32, 0173; G_GFX9-NEXT: ds_write_b32 v4, v3174; G_GFX9-NEXT: s_waitcnt lgkmcnt(0)175; G_GFX9-NEXT: s_swappc_b64 s[30:31], s[18:19]176; G_GFX9-NEXT: s_endpgm177;178; G_GFX10-LABEL: withcall:179; G_GFX10: ; %bb.0:180; G_GFX10-NEXT: s_mov_b32 s20, SCRATCH_RSRC_DWORD0181; G_GFX10-NEXT: s_mov_b32 s21, SCRATCH_RSRC_DWORD1182; G_GFX10-NEXT: s_mov_b32 s22, -1183; G_GFX10-NEXT: s_mov_b32 s23, 0x31c16000184; G_GFX10-NEXT: s_add_u32 s20, s20, s11185; G_GFX10-NEXT: s_addc_u32 s21, s21, 0186; G_GFX10-NEXT: s_mov_b32 s16, s8187; G_GFX10-NEXT: s_add_u32 s8, s4, 36188; G_GFX10-NEXT: s_mov_b32 s15, s9189; G_GFX10-NEXT: s_addc_u32 s9, s5, 0190; G_GFX10-NEXT: s_mov_b64 s[12:13], s[0:1]191; G_GFX10-NEXT: s_getpc_b64 s[0:1]192; G_GFX10-NEXT: s_add_u32 s0, s0, nonkernel@gotpcrel32@lo+4193; G_GFX10-NEXT: s_addc_u32 s1, s1, nonkernel@gotpcrel32@hi+12194; G_GFX10-NEXT: v_lshlrev_b32_e32 v1, 10, v1195; G_GFX10-NEXT: s_load_dwordx2 s[18:19], s[0:1], 0x0196; G_GFX10-NEXT: v_lshlrev_b32_e32 v2, 20, v2197; G_GFX10-NEXT: v_mov_b32_e32 v3, 0198; G_GFX10-NEXT: v_mov_b32_e32 v4, 8199; G_GFX10-NEXT: s_mov_b32 s14, s10200; G_GFX10-NEXT: s_mov_b64 s[10:11], s[6:7]201; G_GFX10-NEXT: v_or3_b32 v31, v0, v1, v2202; G_GFX10-NEXT: s_mov_b64 s[6:7], s[2:3]203; G_GFX10-NEXT: s_mov_b64 s[0:1], s[20:21]204; G_GFX10-NEXT: s_mov_b64 s[2:3], s[22:23]205; G_GFX10-NEXT: s_mov_b64 s[4:5], s[12:13]206; G_GFX10-NEXT: s_mov_b32 s12, s16207; G_GFX10-NEXT: s_mov_b32 s13, s15208; G_GFX10-NEXT: s_mov_b32 s32, 0209; G_GFX10-NEXT: ds_write_b32 v4, v3210; G_GFX10-NEXT: s_waitcnt lgkmcnt(0)211; G_GFX10-NEXT: s_swappc_b64 s[30:31], s[18:19]212; G_GFX10-NEXT: s_endpgm213 store i32 0, ptr addrspace(3) @used_by_both214 call void @nonkernel()215 ret void216}217; CHECK: ; LDSByteSize: 16 bytes218 219; Previous lowering was less efficient here than necessary as the i32 used220; by the kernel is also used by an unrelated non-kernel function. Codegen221; is now the same as nocall_ideal.222define amdgpu_kernel void @nocall_false_sharing() {223; CHECK-LABEL: nocall_false_sharing:224; CHECK: ; %bb.0:225; CHECK-NEXT: v_mov_b32_e32 v0, 0226; CHECK-NEXT: ds_write_b32 v0, v0227; CHECK-NEXT: s_endpgm228 store i32 0, ptr addrspace(3) @used_by_both229 ret void230}231; CHECK: ; LDSByteSize: 4 bytes232 233