Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / whole-wave-register-copy.ll
blobcfb1cffdb509648d960d3de19969caf23c18b028
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -verify-machineinstrs < %s | FileCheck -check-prefix=GFX90A %s
4 ; The test forces a high vector register pressure and there won't be sufficient VGPRs to be allocated
5 ; for writelane/readlane SGPR spill instructions. Regalloc would split the vector register liverange
6 ; by introducing a copy to AGPR register. The VGPR store to AGPR (v_accvgpr_write_b32) and later the
7 ; restore from AGPR (v_accvgpr_read_b32) should be whole-wave operations and hence exec mask should be
8 ; manipulated to ensure all lanes are active when these instructions are executed.
9 define void @vector_reg_liverange_split() #0 {
10 ; GFX90A-LABEL: vector_reg_liverange_split:
11 ; GFX90A:       ; %bb.0:
12 ; GFX90A-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
13 ; GFX90A-NEXT:    s_mov_b32 s16, s33
14 ; GFX90A-NEXT:    s_mov_b32 s33, s32
15 ; GFX90A-NEXT:    s_xor_saveexec_b64 s[18:19], -1
16 ; GFX90A-NEXT:    buffer_store_dword v0, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill
17 ; GFX90A-NEXT:    s_mov_b64 exec, -1
18 ; GFX90A-NEXT:    buffer_store_dword v40, off, s[0:3], s33 ; 4-byte Folded Spill
19 ; GFX90A-NEXT:    buffer_store_dword a32, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill
20 ; GFX90A-NEXT:    s_mov_b64 exec, s[18:19]
21 ; GFX90A-NEXT:    v_writelane_b32 v40, s16, 2
22 ; GFX90A-NEXT:    ; implicit-def: $vgpr0 : SGPR spill to VGPR lane
23 ; GFX90A-NEXT:    v_writelane_b32 v40, s30, 0
24 ; GFX90A-NEXT:    s_addk_i32 s32, 0x400
25 ; GFX90A-NEXT:    v_writelane_b32 v40, s31, 1
26 ; GFX90A-NEXT:    ;;#ASMSTART
27 ; GFX90A-NEXT:    ; def s20
28 ; GFX90A-NEXT:    ;;#ASMEND
29 ; GFX90A-NEXT:    v_writelane_b32 v0, s20, 0
30 ; GFX90A-NEXT:    s_or_saveexec_b64 s[28:29], -1
31 ; GFX90A-NEXT:    v_accvgpr_write_b32 a32, v0
32 ; GFX90A-NEXT:    s_mov_b64 exec, s[28:29]
33 ; GFX90A-NEXT:    s_getpc_b64 s[16:17]
34 ; GFX90A-NEXT:    s_add_u32 s16, s16, foo@gotpcrel32@lo+4
35 ; GFX90A-NEXT:    s_addc_u32 s17, s17, foo@gotpcrel32@hi+12
36 ; GFX90A-NEXT:    s_load_dwordx2 s[16:17], s[16:17], 0x0
37 ; GFX90A-NEXT:    s_waitcnt lgkmcnt(0)
38 ; GFX90A-NEXT:    s_swappc_b64 s[30:31], s[16:17]
39 ; GFX90A-NEXT:    s_or_saveexec_b64 s[28:29], -1
40 ; GFX90A-NEXT:    v_accvgpr_read_b32 v0, a32
41 ; GFX90A-NEXT:    s_mov_b64 exec, s[28:29]
42 ; GFX90A-NEXT:    v_readlane_b32 s20, v0, 0
43 ; GFX90A-NEXT:    ;;#ASMSTART
44 ; GFX90A-NEXT:    ; use s20
45 ; GFX90A-NEXT:    ;;#ASMEND
46 ; GFX90A-NEXT:    v_readlane_b32 s31, v40, 1
47 ; GFX90A-NEXT:    v_readlane_b32 s30, v40, 0
48 ; GFX90A-NEXT:    ; kill: killed $vgpr0
49 ; GFX90A-NEXT:    v_readlane_b32 s4, v40, 2
50 ; GFX90A-NEXT:    s_xor_saveexec_b64 s[6:7], -1
51 ; GFX90A-NEXT:    buffer_load_dword v0, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload
52 ; GFX90A-NEXT:    s_mov_b64 exec, -1
53 ; GFX90A-NEXT:    buffer_load_dword v40, off, s[0:3], s33 ; 4-byte Folded Reload
54 ; GFX90A-NEXT:    buffer_load_dword a32, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload
55 ; GFX90A-NEXT:    s_mov_b64 exec, s[6:7]
56 ; GFX90A-NEXT:    s_addk_i32 s32, 0xfc00
57 ; GFX90A-NEXT:    s_mov_b32 s33, s4
58 ; GFX90A-NEXT:    s_waitcnt vmcnt(0)
59 ; GFX90A-NEXT:    s_setpc_b64 s[30:31]
60   %s20 = call i32 asm sideeffect "; def $0","=${s20}"()
61   call void @foo()
62   call void asm sideeffect "; use $0","${s20}"(i32 %s20)
63   ret void
66 declare void @foo()
68 attributes #0 = { "amdgpu-num-vgpr"="41" "amdgpu-num-sgpr"="34"}