File: whole-wave-register-copy.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,064 kB
  • sloc: cpp: 7,619,731; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,676; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (71 lines) | stat: -rw-r--r-- 3,495 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -verify-machineinstrs < %s | FileCheck -check-prefix=GFX90A %s

; The test forces a high vector register pressure and there won't be sufficient VGPRs to be allocated
; for writelane/readlane SGPR spill instructions. Regalloc would split the vector register liverange
; by introducing a copy to AGPR register. The VGPR store to AGPR (v_accvgpr_write_b32) and later the
; restore from AGPR (v_accvgpr_read_b32) should be whole-wave operations and hence exec mask should be
; manipulated to ensure all lanes are active when these instructions are executed.
define void @vector_reg_liverange_split() #0 {
; GFX90A-LABEL: vector_reg_liverange_split:
; GFX90A:       ; %bb.0:
; GFX90A-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX90A-NEXT:    s_mov_b32 s16, s33
; GFX90A-NEXT:    s_mov_b32 s33, s32
; GFX90A-NEXT:    s_xor_saveexec_b64 s[18:19], -1
; GFX90A-NEXT:    buffer_store_dword v39, off, s[0:3], s33 offset:4 ; 4-byte Folded Spill
; GFX90A-NEXT:    s_mov_b64 exec, -1
; GFX90A-NEXT:    buffer_store_dword a32, off, s[0:3], s33 ; 4-byte Folded Spill
; GFX90A-NEXT:    buffer_store_dword v40, off, s[0:3], s33 offset:8 ; 4-byte Folded Spill
; GFX90A-NEXT:    s_mov_b64 exec, s[18:19]
; GFX90A-NEXT:    v_writelane_b32 v40, s16, 4
; GFX90A-NEXT:    v_writelane_b32 v40, s28, 2
; GFX90A-NEXT:    v_writelane_b32 v40, s29, 3
; GFX90A-NEXT:    v_writelane_b32 v40, s30, 0
; GFX90A-NEXT:    ; implicit-def: $vgpr39 : SGPR spill to VGPR lane
; GFX90A-NEXT:    s_addk_i32 s32, 0x400
; GFX90A-NEXT:    v_writelane_b32 v40, s31, 1
; GFX90A-NEXT:    ;;#ASMSTART
; GFX90A-NEXT:    ; def s20
; GFX90A-NEXT:    ;;#ASMEND
; GFX90A-NEXT:    v_writelane_b32 v39, s20, 0
; GFX90A-NEXT:    s_or_saveexec_b64 s[28:29], -1
; GFX90A-NEXT:    v_accvgpr_write_b32 a32, v39
; GFX90A-NEXT:    s_mov_b64 exec, s[28:29]
; GFX90A-NEXT:    s_getpc_b64 s[16:17]
; GFX90A-NEXT:    s_add_u32 s16, s16, foo@gotpcrel32@lo+4
; GFX90A-NEXT:    s_addc_u32 s17, s17, foo@gotpcrel32@hi+12
; GFX90A-NEXT:    s_load_dwordx2 s[16:17], s[16:17], 0x0
; GFX90A-NEXT:    s_waitcnt lgkmcnt(0)
; GFX90A-NEXT:    s_swappc_b64 s[30:31], s[16:17]
; GFX90A-NEXT:    s_or_saveexec_b64 s[28:29], -1
; GFX90A-NEXT:    v_accvgpr_read_b32 v39, a32
; GFX90A-NEXT:    s_mov_b64 exec, s[28:29]
; GFX90A-NEXT:    v_readlane_b32 s20, v39, 0
; GFX90A-NEXT:    ;;#ASMSTART
; GFX90A-NEXT:    ; use s20
; GFX90A-NEXT:    ;;#ASMEND
; GFX90A-NEXT:    v_readlane_b32 s31, v40, 1
; GFX90A-NEXT:    v_readlane_b32 s30, v40, 0
; GFX90A-NEXT:    s_mov_b32 s32, s33
; GFX90A-NEXT:    v_readlane_b32 s4, v40, 4
; GFX90A-NEXT:    v_readlane_b32 s28, v40, 2
; GFX90A-NEXT:    v_readlane_b32 s29, v40, 3
; GFX90A-NEXT:    s_xor_saveexec_b64 s[6:7], -1
; GFX90A-NEXT:    buffer_load_dword v39, off, s[0:3], s33 offset:4 ; 4-byte Folded Reload
; GFX90A-NEXT:    s_mov_b64 exec, -1
; GFX90A-NEXT:    buffer_load_dword a32, off, s[0:3], s33 ; 4-byte Folded Reload
; GFX90A-NEXT:    buffer_load_dword v40, off, s[0:3], s33 offset:8 ; 4-byte Folded Reload
; GFX90A-NEXT:    s_mov_b64 exec, s[6:7]
; GFX90A-NEXT:    s_mov_b32 s33, s4
; GFX90A-NEXT:    s_waitcnt vmcnt(0)
; GFX90A-NEXT:    s_setpc_b64 s[30:31]
  %s20 = call i32 asm sideeffect "; def $0","=${s20}"()
  call void @foo()
  call void asm sideeffect "; use $0","${s20}"(i32 %s20)
  ret void
}

declare void @foo()

attributes #0 = { "amdgpu-num-vgpr"="41" "amdgpu-num-sgpr"="34"}