1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9 %s 2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX10 %s 3 4declare void @extern_func() 5 6define <4 x float> @non_preserved_vgpr_tuple8(<8 x i32> %rsrc, <4 x i32> %samp, float %bias, float %zcompare, float %s, float %t, float %clamp) { 7; The vgpr tuple8 operand in image_gather4_c_b_cl instruction needs not be 8; preserved across the call and should get 8 scratch registers. 9 10; GFX9-LABEL: non_preserved_vgpr_tuple8: 11; GFX9: buffer_store_dword v44, off, s[0:3], s32 offset:16 ; 4-byte Folded Spill 12; GFX9: buffer_store_dword v40, off, s[0:3], s33 offset:12 ; 4-byte Folded Spill 13; GFX9-NEXT: buffer_store_dword v41, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill 14; GFX9-NEXT: buffer_store_dword v42, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill 15; GFX9-NEXT: buffer_store_dword v43, off, s[0:3], s33 ; 4-byte Folded Spill 16 17; GFX9: v_writelane_b32 v44, s30, 0 18; GFX9-NEXT: v_mov_b32_e32 v36, v16 19; GFX9-NEXT: v_mov_b32_e32 v35, v15 20; GFX9-NEXT: v_mov_b32_e32 v34, v14 21; GFX9-NEXT: v_mov_b32_e32 v33, v13 22; GFX9-NEXT: v_mov_b32_e32 v32, v12 23 24; GFX9: ;;#ASMSTART 25; GFX9-NEXT: ;;#ASMEND 26 27; GFX9: image_gather4_c_b_cl v[40:43], v[32:39], s[4:11], s[4:7] dmask:0x1 28; GFX9-NEXT: s_getpc_b64 s[4:5] 29; GFX9-NEXT: s_add_u32 s4, s4, extern_func@gotpcrel32@lo+4 30; GFX9-NEXT: s_addc_u32 s5, s5, extern_func@gotpcrel32@hi+12 31; GFX9-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 32; GFX9-NEXT: s_waitcnt lgkmcnt(0) 33; GFX9-NEXT: s_swappc_b64 s[30:31], s[4:5] 34 35; GFX9: buffer_load_dword v43, off, s[0:3], s33 ; 4-byte Folded Reload 36; GFX9-NEXT: buffer_load_dword v42, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload 37; GFX9-NEXT: buffer_load_dword v41, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload 38; GFX9-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:12 ; 4-byte Folded Reload 39; GFX9: buffer_load_dword v44, off, s[0:3], s32 offset:16 ; 4-byte Folded Reload 40; GFX9: s_setpc_b64 s[4:5] 41; 42; GFX10-LABEL: non_preserved_vgpr_tuple8: 43; GFX10: buffer_store_dword v44, off, s[0:3], s32 offset:16 ; 4-byte Folded Spill 44; GFX10: buffer_store_dword v40, off, s[0:3], s33 offset:12 ; 4-byte Folded Spill 45; GFX10-NEXT: buffer_store_dword v41, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill 46; GFX10-NEXT: buffer_store_dword v42, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill 47; GFX10-NEXT: buffer_store_dword v43, off, s[0:3], s33 ; 4-byte Folded Spill 48 49; GFX10: v_mov_b32_e32 v36, v16 50; GFX10-NEXT: v_mov_b32_e32 v35, v15 51; GFX10-NEXT: v_mov_b32_e32 v34, v14 52; GFX10-NEXT: v_mov_b32_e32 v33, v13 53; GFX10-NEXT: v_mov_b32_e32 v32, v12 54 55; GFX10: ;;#ASMSTART 56; GFX10-NEXT: ;;#ASMEND 57 58; GFX10: image_gather4_c_b_cl v[40:43], v[32:39], s[4:11], s[4:7] dmask:0x1 dim:SQ_RSRC_IMG_2D 59; GFX10-NEXT: s_waitcnt_depctr 0xffe3 60; GFX10-NEXT: s_getpc_b64 s[4:5] 61; GFX10-NEXT: s_add_u32 s4, s4, extern_func@gotpcrel32@lo+4 62; GFX10-NEXT: s_addc_u32 s5, s5, extern_func@gotpcrel32@hi+12 63; GFX10-NEXT: ; implicit-def: $vcc_hi 64; GFX10-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 65; GFX10-NEXT: s_waitcnt lgkmcnt(0) 66; GFX10-NEXT: s_swappc_b64 s[30:31], s[4:5] 67 68; GFX10: buffer_load_dword v43, off, s[0:3], s33 69; GFX10-NEXT: buffer_load_dword v42, off, s[0:3], s33 offset:4 70; GFX10-NEXT: buffer_load_dword v41, off, s[0:3], s33 offset:8 71; GFX10-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:12 72 73; GFX10: buffer_load_dword v44, off, s[0:3], s32 offset:16 ; 4-byte Folded Reload 74; GFX10: s_setpc_b64 s[4:5] 75main_body: 76 call void asm sideeffect "", "~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7}"() #0 77 call void asm sideeffect "", "~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15}"() #0 78 call void asm sideeffect "", "~{v16},~{v17},~{v18},~{v19},~{v20},~{v21},~{v22},~{v23}"() #0 79 call void asm sideeffect "", "~{v24},~{v25},~{v26},~{v27},~{v28},~{v29},~{v30},~{v31}"() #0 80 %v = call <4 x float> @llvm.amdgcn.image.gather4.c.b.cl.2d.v4f32.f32.f32(i32 1, float %bias, float %zcompare, float %s, float %t, float %clamp, <8 x i32> undef, <4 x i32> undef, i1 false, i32 0, i32 0) 81 call void @extern_func() 82 ret <4 x float> %v 83} 84 85define <4 x float> @call_preserved_vgpr_tuple8(<8 x i32> %rsrc, <4 x i32> %samp, float %bias, float %zcompare, float %s, float %t, float %clamp) { 86; The vgpr tuple8 operand in image_gather4_c_b_cl instruction needs to be preserved 87; across the call and should get allcoated to 8 CSRs. 88; Only the lower 5 sub-registers of the tuple are preserved. 89; The upper 3 sub-registers are unused. 90 91; GFX9-LABEL: call_preserved_vgpr_tuple8: 92; GFX9: buffer_store_dword v56, off, s[0:3], s32 offset:20 ; 4-byte Folded Spill 93; GFX9: buffer_store_dword v40, off, s[0:3], s33 offset:16 ; 4-byte Folded Spill 94; GFX9-NEXT: buffer_store_dword v41, off, s[0:3], s33 offset:12 ; 4-byte Folded Spill 95; GFX9-NEXT: buffer_store_dword v42, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill 96; GFX9-NEXT: buffer_store_dword v43, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill 97; GFX9-NEXT: buffer_store_dword v44, off, s[0:3], s33 ; 4-byte Folded Spill 98 99; GFX9: v_mov_b32_e32 v44, v16 100; GFX9-NEXT: v_mov_b32_e32 v43, v15 101; GFX9-NEXT: v_mov_b32_e32 v42, v14 102; GFX9-NEXT: v_mov_b32_e32 v41, v13 103; GFX9-NEXT: v_mov_b32_e32 v40, v12 104 105; GFX9: image_gather4_c_b_cl v[0:3], v[40:47], s[36:43], s[4:7] dmask:0x1 106; GFX9-NEXT: s_getpc_b64 s[4:5] 107; GFX9-NEXT: s_add_u32 s4, s4, extern_func@gotpcrel32@lo+4 108; GFX9-NEXT: s_addc_u32 s5, s5, extern_func@gotpcrel32@hi+12 109; GFX9-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 110; GFX9-NEXT: s_waitcnt vmcnt(0) 111; GFX9-NEXT: global_store_dwordx4 v[0:1], v[0:3], off 112; GFX9-NEXT: s_waitcnt lgkmcnt(0) 113; GFX9-NEXT: s_swappc_b64 s[30:31], s[4:5] 114; GFX9-NEXT: image_gather4_c_b_cl v[0:3], v[40:47], s[36:43], s[4:7] dmask:0x1 115 116; GFX9: buffer_load_dword v44, off, s[0:3], s33 ; 4-byte Folded Reload 117; GFX9-NEXT: buffer_load_dword v43, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload 118; GFX9-NEXT: buffer_load_dword v42, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload 119; GFX9-NEXT: buffer_load_dword v41, off, s[0:3], s33 offset:12 ; 4-byte Folded Reload 120; GFX9-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:16 ; 4-byte Folded Reload 121 122; GFX9: buffer_load_dword v56, off, s[0:3], s32 offset:20 ; 4-byte Folded Reload 123; GFX9: s_setpc_b64 s[4:5] 124; 125; GFX10-LABEL: call_preserved_vgpr_tuple8: 126; GFX10: buffer_store_dword v45, off, s[0:3], s32 offset:20 ; 4-byte Folded Spill 127; GFX10: buffer_store_dword v40, off, s[0:3], s33 offset:16 ; 4-byte Folded Spill 128; GFX10-NEXT: buffer_store_dword v41, off, s[0:3], s33 offset:12 ; 4-byte Folded Spill 129; GFX10-NEXT: buffer_store_dword v42, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill 130; GFX10-NEXT: buffer_store_dword v43, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill 131; GFX10-NEXT: buffer_store_dword v44, off, s[0:3], s33 ; 4-byte Folded Spill 132 133 134; GFX10: image_gather4_c_b_cl v[0:3], v[12:19], s[36:43], s[4:7] dmask:0x1 dim:SQ_RSRC_IMG_2D 135; GFX10-NEXT: s_waitcnt_depctr 0xffe3 136; GFX10-NEXT: s_getpc_b64 s[4:5] 137; GFX10-NEXT: s_add_u32 s4, s4, extern_func@gotpcrel32@lo+4 138; GFX10-NEXT: s_addc_u32 s5, s5, extern_func@gotpcrel32@hi+12 139; GFX10-NEXT: v_mov_b32_e32 v41, v15 140; GFX10-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 141; GFX10-NEXT: v_mov_b32_e32 v42, v14 142; GFX10-NEXT: v_mov_b32_e32 v43, v13 143; GFX10-NEXT: v_mov_b32_e32 v44, v12 144; GFX10-NEXT: ; implicit-def: $vcc_hi 145; GFX10-NEXT: s_waitcnt vmcnt(0) 146; GFX10-NEXT: global_store_dwordx4 v[0:1], v[0:3], off 147; GFX10-NEXT: s_waitcnt lgkmcnt(0) 148; GFX10-NEXT: s_swappc_b64 s[30:31], s[4:5] 149; GFX10-NEXT: image_gather4_c_b_cl v[0:3], [v44, v43, v42, v41, v40], s[36:43], s[4:7] dmask:0x1 dim:SQ_RSRC_IMG_2D 150 151; GFX10: buffer_load_dword v44, off, s[0:3], s33 152; GFX10-NEXT: buffer_load_dword v43, off, s[0:3], s33 offset:4 153; GFX10-NEXT: buffer_load_dword v42, off, s[0:3], s33 offset:8 154; GFX10-NEXT: buffer_load_dword v41, off, s[0:3], s33 offset:12 155; GFX10-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:16 156; GFX10: buffer_load_dword v45, off, s[0:3], s32 offset:20 157; GFX10: s_setpc_b64 s[4:5] 158main_body: 159 %v = call <4 x float> @llvm.amdgcn.image.gather4.c.b.cl.2d.v4f32.f32.f32(i32 1, float %bias, float %zcompare, float %s, float %t, float %clamp, <8 x i32> undef, <4 x i32> undef, i1 false, i32 0, i32 0) 160 store <4 x float> %v, <4 x float> addrspace(1)* undef 161 call void @extern_func() 162 %v1 = call <4 x float> @llvm.amdgcn.image.gather4.c.b.cl.2d.v4f32.f32.f32(i32 1, float %bias, float %zcompare, float %s, float %t, float %clamp, <8 x i32> undef, <4 x i32> undef, i1 false, i32 0, i32 0) 163 ret <4 x float> %v1 164} 165 166declare <4 x float> @llvm.amdgcn.image.gather4.c.b.cl.2d.v4f32.f32.f32(i32 immarg, float, float, float, float, float, <8 x i32>, <4 x i32>, i1 immarg, i32 immarg, i32 immarg) #1 167 168attributes #0 = { nounwind writeonly } 169attributes #1 = { nounwind readonly } 170