137 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -o - %s | FileCheck -check-prefix=GCN %s3; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -O0 -o - %s | FileCheck -check-prefix=GCN-O0 %s4 5; Test whole-wave register spilling.6 7; In this testcase, the return address registers, PC value (SGPR30_SGPR31) and the scratch SGPR used in8; the inline asm statements should be preserved across the call. Since the test limits the VGPR numbers,9; the PC will be spilled to the only available CSR VGPR (VGPR40) as we spill CSR SGPRs including the PC10; directly to the physical VGPR lane to correctly generate the CFIs. The SGPR20 will get spilled to the11; virtual VGPR lane and that would be allocated by regalloc. Since there is no free VGPR to allocate, RA12; must spill a scratch VGPR. The writelane/readlane instructions that spill/restore SGPRs into/from VGPR13; are whole-wave operations and hence the VGPRs involved in such operations require whole-wave spilling.14 15define void @test() #0 {16; GCN-LABEL: test:17; GCN: ; %bb.0:18; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)19; GCN-NEXT: s_mov_b32 s16, s3320; GCN-NEXT: s_mov_b32 s33, s3221; GCN-NEXT: s_xor_saveexec_b64 s[18:19], -122; GCN-NEXT: buffer_store_dword v39, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill23; GCN-NEXT: s_mov_b64 exec, -124; GCN-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill25; GCN-NEXT: s_mov_b64 exec, s[18:19]26; GCN-NEXT: v_writelane_b32 v40, s16, 427; GCN-NEXT: v_writelane_b32 v40, s28, 228; GCN-NEXT: v_writelane_b32 v40, s29, 329; GCN-NEXT: v_writelane_b32 v40, s30, 030; GCN-NEXT: ; implicit-def: $vgpr39 : SGPR spill to VGPR lane31; GCN-NEXT: s_addk_i32 s32, 0x40032; GCN-NEXT: v_writelane_b32 v40, s31, 133; GCN-NEXT: ;;#ASMSTART34; GCN-NEXT: ; def s1635; GCN-NEXT: ;;#ASMEND36; GCN-NEXT: v_writelane_b32 v39, s16, 037; GCN-NEXT: s_or_saveexec_b64 s[28:29], -138; GCN-NEXT: buffer_store_dword v39, off, s[0:3], s33 ; 4-byte Folded Spill39; GCN-NEXT: s_mov_b64 exec, s[28:29]40; GCN-NEXT: s_getpc_b64 s[16:17]41; GCN-NEXT: s_add_u32 s16, s16, ext_func@gotpcrel32@lo+442; GCN-NEXT: s_addc_u32 s17, s17, ext_func@gotpcrel32@hi+1243; GCN-NEXT: s_load_dwordx2 s[16:17], s[16:17], 0x044; GCN-NEXT: s_waitcnt lgkmcnt(0)45; GCN-NEXT: s_swappc_b64 s[30:31], s[16:17]46; GCN-NEXT: s_or_saveexec_b64 s[28:29], -147; GCN-NEXT: buffer_load_dword v39, off, s[0:3], s33 ; 4-byte Folded Reload48; GCN-NEXT: s_mov_b64 exec, s[28:29]49; GCN-NEXT: s_waitcnt vmcnt(0)50; GCN-NEXT: v_readlane_b32 s4, v39, 051; GCN-NEXT: v_mov_b32_e32 v0, s452; GCN-NEXT: global_store_dword v[0:1], v0, off53; GCN-NEXT: s_waitcnt vmcnt(0)54; GCN-NEXT: v_readlane_b32 s31, v40, 155; GCN-NEXT: v_readlane_b32 s30, v40, 056; GCN-NEXT: s_mov_b32 s32, s3357; GCN-NEXT: v_readlane_b32 s4, v40, 458; GCN-NEXT: v_readlane_b32 s28, v40, 259; GCN-NEXT: v_readlane_b32 s29, v40, 360; GCN-NEXT: s_xor_saveexec_b64 s[6:7], -161; GCN-NEXT: buffer_load_dword v39, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload62; GCN-NEXT: s_mov_b64 exec, -163; GCN-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload64; GCN-NEXT: s_mov_b64 exec, s[6:7]65; GCN-NEXT: s_mov_b32 s33, s466; GCN-NEXT: s_waitcnt vmcnt(0)67; GCN-NEXT: s_setpc_b64 s[30:31]68;69; GCN-O0-LABEL: test:70; GCN-O0: ; %bb.0:71; GCN-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)72; GCN-O0-NEXT: s_mov_b32 s16, s3373; GCN-O0-NEXT: s_mov_b32 s33, s3274; GCN-O0-NEXT: s_xor_saveexec_b64 s[18:19], -175; GCN-O0-NEXT: buffer_store_dword v39, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill76; GCN-O0-NEXT: s_mov_b64 exec, -177; GCN-O0-NEXT: buffer_store_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill78; GCN-O0-NEXT: s_mov_b64 exec, s[18:19]79; GCN-O0-NEXT: v_writelane_b32 v40, s16, 480; GCN-O0-NEXT: v_writelane_b32 v40, s28, 281; GCN-O0-NEXT: v_writelane_b32 v40, s29, 382; GCN-O0-NEXT: s_add_i32 s32, s32, 0x40083; GCN-O0-NEXT: v_writelane_b32 v40, s30, 084; GCN-O0-NEXT: v_writelane_b32 v40, s31, 185; GCN-O0-NEXT: ;;#ASMSTART86; GCN-O0-NEXT: ; def s1687; GCN-O0-NEXT: ;;#ASMEND88; GCN-O0-NEXT: ; implicit-def: $vgpr39 : SGPR spill to VGPR lane89; GCN-O0-NEXT: v_writelane_b32 v39, s16, 090; GCN-O0-NEXT: s_or_saveexec_b64 s[28:29], -191; GCN-O0-NEXT: buffer_store_dword v39, off, s[0:3], s33 ; 4-byte Folded Spill92; GCN-O0-NEXT: s_mov_b64 exec, s[28:29]93; GCN-O0-NEXT: s_getpc_b64 s[16:17]94; GCN-O0-NEXT: s_add_u32 s16, s16, ext_func@gotpcrel32@lo+495; GCN-O0-NEXT: s_addc_u32 s17, s17, ext_func@gotpcrel32@hi+1296; GCN-O0-NEXT: s_load_dwordx2 s[16:17], s[16:17], 0x097; GCN-O0-NEXT: s_mov_b64 s[22:23], s[2:3]98; GCN-O0-NEXT: s_mov_b64 s[20:21], s[0:1]99; GCN-O0-NEXT: s_mov_b64 s[0:1], s[20:21]100; GCN-O0-NEXT: s_mov_b64 s[2:3], s[22:23]101; GCN-O0-NEXT: s_waitcnt lgkmcnt(0)102; GCN-O0-NEXT: s_swappc_b64 s[30:31], s[16:17]103; GCN-O0-NEXT: s_or_saveexec_b64 s[28:29], -1104; GCN-O0-NEXT: buffer_load_dword v39, off, s[0:3], s33 ; 4-byte Folded Reload105; GCN-O0-NEXT: s_mov_b64 exec, s[28:29]106; GCN-O0-NEXT: s_waitcnt vmcnt(0)107; GCN-O0-NEXT: v_readlane_b32 s4, v39, 0108; GCN-O0-NEXT: ; implicit-def: $sgpr6_sgpr7109; GCN-O0-NEXT: v_mov_b32_e32 v0, s6110; GCN-O0-NEXT: v_mov_b32_e32 v1, s7111; GCN-O0-NEXT: v_mov_b32_e32 v2, s4112; GCN-O0-NEXT: global_store_dword v[0:1], v2, off113; GCN-O0-NEXT: s_waitcnt vmcnt(0)114; GCN-O0-NEXT: v_readlane_b32 s31, v40, 1115; GCN-O0-NEXT: v_readlane_b32 s30, v40, 0116; GCN-O0-NEXT: s_mov_b32 s32, s33117; GCN-O0-NEXT: v_readlane_b32 s4, v40, 4118; GCN-O0-NEXT: v_readlane_b32 s28, v40, 2119; GCN-O0-NEXT: v_readlane_b32 s29, v40, 3120; GCN-O0-NEXT: s_xor_saveexec_b64 s[6:7], -1121; GCN-O0-NEXT: buffer_load_dword v39, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload122; GCN-O0-NEXT: s_mov_b64 exec, -1123; GCN-O0-NEXT: buffer_load_dword v40, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload124; GCN-O0-NEXT: s_mov_b64 exec, s[6:7]125; GCN-O0-NEXT: s_mov_b32 s33, s4126; GCN-O0-NEXT: s_waitcnt vmcnt(0)127; GCN-O0-NEXT: s_setpc_b64 s[30:31]128 %sgpr = call i32 asm sideeffect "; def $0", "=s" () #0129 call void @ext_func()130 store volatile i32 %sgpr, ptr addrspace(1) poison131 ret void132}133 134declare void @ext_func();135 136attributes #0 = { nounwind "amdgpu-num-vgpr"="41" "amdgpu-num-sgpr"="34"}137