1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=greedy -verify-machineinstrs -o - %s |FileCheck %s
4 # Testcase is limited to 24 VGPRs. Only a maximum of 6 vreg_128s can
5 # be allocated at the same time.
7 # This testcase is intended to stress the heuristic in
8 # RAGreedy::enqueue to switch from local to global. If an interval is
9 # in one basic block, the usual preference is to allocate registers in
10 # instruction order. If the estimated live range length is more than
11 # twice the number of registers in the class, the global heuristic is
12 # used which increases the priority of the longest live ranges. By
13 # accounting for the number of reserved registers in vreg_128, the
14 # heuristic changes end up avoiding a spill of %0.
18 define void @use_global_assign() #0 {
23 attributes #0 = { "amdgpu-waves-per-eu"="10,10" }
27 name: use_global_assign
28 tracksRegLiveness: true
30 - { id: 0, class: vreg_128, preferred-register: '%0' }
31 - { id: 1, class: vreg_128, preferred-register: '%0' }
32 - { id: 2, class: vreg_128, preferred-register: '%0' }
33 - { id: 3, class: vreg_128, preferred-register: '%0' }
34 - { id: 4, class: vreg_128, preferred-register: '%0' }
35 - { id: 5, class: vreg_128, preferred-register: '%0' }
36 - { id: 6, class: vreg_128, preferred-register: '%0' }
37 - { id: 7, class: vreg_128, preferred-register: '%0' }
38 - { id: 8, class: vreg_128, preferred-register: '%0' }
39 - { id: 9, class: vreg_128, preferred-register: '%0' }
40 - { id: 10, class: vreg_128, preferred-register: '%0' }
41 - { id: 11, class: vreg_128, preferred-register: '%0' }
42 - { id: 12, class: vreg_128, preferred-register: '%0' }
43 - { id: 13, class: vreg_128, preferred-register: '%0' }
44 - { id: 14, class: vreg_128, preferred-register: '%0' }
45 - { id: 15, class: vreg_128, preferred-register: '%0' }
49 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
50 stackPtrOffsetReg: '$sgpr32'
52 ; CHECK-LABEL: name: use_global_assign
54 ; CHECK-NEXT: successors: %bb.1(0x80000000)
56 ; CHECK-NEXT: S_NOP 0, implicit-def %0
57 ; CHECK-NEXT: S_NOP 0, implicit-def %18
58 ; CHECK-NEXT: SI_SPILL_V128_SAVE %18, %stack.0, $sgpr32, 0, implicit $exec :: (store (s128) into %stack.0, align 4, addrspace 5)
59 ; CHECK-NEXT: S_NOP 0, implicit-def %35
60 ; CHECK-NEXT: S_NOP 0, implicit-def %27
61 ; CHECK-NEXT: S_NOP 0, implicit-def %29
62 ; CHECK-NEXT: S_NOP 0, implicit-def %31
65 ; CHECK-NEXT: successors: %bb.2(0x80000000)
67 ; CHECK-NEXT: S_NOP 0, implicit %31
68 ; CHECK-NEXT: S_NOP 0, implicit %29
69 ; CHECK-NEXT: S_NOP 0, implicit %27
70 ; CHECK-NEXT: S_NOP 0, implicit %35
71 ; CHECK-NEXT: SI_SPILL_V128_SAVE %35, %stack.1, $sgpr32, 0, implicit $exec :: (store (s128) into %stack.1, align 4, addrspace 5)
72 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.0, align 4, addrspace 5)
73 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE]]
74 ; CHECK-NEXT: S_NOP 0, implicit %0
75 ; CHECK-NEXT: S_NOP 0, implicit-def %10
83 ; CHECK-NEXT: S_NOP 0, implicit %0
84 ; CHECK-NEXT: S_NOP 0, implicit-def %33
85 ; CHECK-NEXT: SI_SPILL_V128_SAVE %33, %stack.2, $sgpr32, 0, implicit $exec :: (store (s128) into %stack.2, align 4, addrspace 5)
86 ; CHECK-NEXT: S_NOP 0, implicit %10
97 ; CHECK-NEXT: S_NOP 0, implicit-def %40
98 ; CHECK-NEXT: SI_SPILL_V128_SAVE %40, %stack.4, $sgpr32, 0, implicit $exec :: (store (s128) into %stack.4, align 4, addrspace 5)
99 ; CHECK-NEXT: S_NOP 0, implicit %33
100 ; CHECK-NEXT: S_NOP 0
101 ; CHECK-NEXT: S_NOP 0
102 ; CHECK-NEXT: S_NOP 0
103 ; CHECK-NEXT: S_NOP 0
104 ; CHECK-NEXT: S_NOP 0
105 ; CHECK-NEXT: S_NOP 0
106 ; CHECK-NEXT: S_NOP 0
107 ; CHECK-NEXT: S_NOP 0
108 ; CHECK-NEXT: S_NOP 0
109 ; CHECK-NEXT: S_NOP 0
110 ; CHECK-NEXT: S_NOP 0
111 ; CHECK-NEXT: S_NOP 0
112 ; CHECK-NEXT: S_NOP 0
113 ; CHECK-NEXT: S_NOP 0
114 ; CHECK-NEXT: S_NOP 0, implicit-def %42
115 ; CHECK-NEXT: SI_SPILL_V128_SAVE %42, %stack.3, $sgpr32, 0, implicit $exec :: (store (s128) into %stack.3, align 4, addrspace 5)
116 ; CHECK-NEXT: S_NOP 0, implicit %40
117 ; CHECK-NEXT: S_NOP 0
118 ; CHECK-NEXT: S_NOP 0
119 ; CHECK-NEXT: S_NOP 0
120 ; CHECK-NEXT: S_NOP 0
121 ; CHECK-NEXT: S_NOP 0
122 ; CHECK-NEXT: S_NOP 0
123 ; CHECK-NEXT: S_NOP 0
124 ; CHECK-NEXT: S_NOP 0
125 ; CHECK-NEXT: S_NOP 0
126 ; CHECK-NEXT: S_NOP 0
127 ; CHECK-NEXT: S_NOP 0
128 ; CHECK-NEXT: S_NOP 0
129 ; CHECK-NEXT: S_NOP 0
130 ; CHECK-NEXT: S_NOP 0
131 ; CHECK-NEXT: S_NOP 0
132 ; CHECK-NEXT: S_NOP 0
133 ; CHECK-NEXT: S_NOP 0
134 ; CHECK-NEXT: S_NOP 0
135 ; CHECK-NEXT: S_NOP 0
136 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vreg_128 = COPY %31
137 ; CHECK-NEXT: S_NOP 0, implicit %31
138 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vreg_128 = COPY %29
139 ; CHECK-NEXT: S_NOP 0, implicit %29
140 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vreg_128 = COPY %27
141 ; CHECK-NEXT: S_NOP 0, implicit %27
142 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE1:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.1, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.1, align 4, addrspace 5)
143 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vreg_128 = COPY [[SI_SPILL_V128_RESTORE1]]
144 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE1]]
145 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE2:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.0, align 4, addrspace 5)
146 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE2]]
147 ; CHECK-NEXT: S_NOP 0, implicit %0
148 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE3:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.2, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.2, align 4, addrspace 5)
149 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE3]]
150 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE4:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.4, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.4, align 4, addrspace 5)
151 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE4]]
152 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE5:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.3, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.3, align 4, addrspace 5)
153 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE5]]
156 ; CHECK-NEXT: S_NOP 0, implicit %0
157 ; CHECK-NEXT: [[SI_SPILL_V128_RESTORE6:%[0-9]+]]:vreg_128 = SI_SPILL_V128_RESTORE %stack.0, $sgpr32, 0, implicit $exec :: (load (s128) from %stack.0, align 4, addrspace 5)
158 ; CHECK-NEXT: S_NOP 0, implicit [[SI_SPILL_V128_RESTORE6]]
159 ; CHECK-NEXT: S_NOP 0, implicit [[COPY3]]
160 ; CHECK-NEXT: S_NOP 0, implicit [[COPY2]]
161 ; CHECK-NEXT: S_NOP 0, implicit [[COPY1]]
162 ; CHECK-NEXT: S_NOP 0, implicit [[COPY]]
164 S_NOP 0, implicit-def %0:vreg_128
165 S_NOP 0, implicit-def %1:vreg_128
166 S_NOP 0, implicit-def %2:vreg_128
167 S_NOP 0, implicit-def %3:vreg_128
168 S_NOP 0, implicit-def %4:vreg_128
169 S_NOP 0, implicit-def %5:vreg_128
178 S_NOP 0, implicit-def %10:vreg_128
187 S_NOP 0, implicit-def %11:vreg_128
188 S_NOP 0, implicit %10
199 S_NOP 0, implicit-def %12:vreg_128
200 S_NOP 0, implicit %11
215 S_NOP 0, implicit-def %13:vreg_128
216 S_NOP 0, implicit %12
242 S_NOP 0, implicit %11
243 S_NOP 0, implicit %12
244 S_NOP 0, implicit %13