1 # RUN: llc -mtriple=s390x-linux-gnu -mcpu=z14 -run-pass greedy %s -o - \
4 # Test that a reload can be folded into a compare instruction after swapping
5 # operands (when the LHS register is spilled).
9 define i64 @fun1(ptr %ptr0) { ret i64 0 }
10 define i64 @fun2(ptr %ptr0) { ret i64 0 }
13 define i32 @fun3(ptr %ptr0) { ret i32 0 }
14 define i32 @fun4(ptr %ptr0) { ret i32 0 }
20 # CHECK: CG %10, %stack.0, 0, $noreg, implicit-def $cc :: (load (s64) from %stack.0)
21 # CHECK-NEXT: %12:gr64bit = LOCGHI %12, 8, 14, 12, implicit $cc
25 tracksRegLiveness: true
27 - { id: 0, class: addr64bit }
28 - { id: 1, class: gr64bit }
29 - { id: 2, class: gr64bit }
30 - { id: 3, class: gr64bit }
31 - { id: 4, class: gr64bit }
32 - { id: 5, class: gr64bit }
33 - { id: 6, class: gr64bit }
34 - { id: 7, class: gr64bit }
35 - { id: 8, class: gr64bit }
36 - { id: 9, class: gr64bit }
37 - { id: 10, class: gr64bit }
38 - { id: 11, class: gr64bit }
39 - { id: 12, class: gr64bit }
40 - { id: 13, class: gr64bit }
41 - { id: 14, class: gr64bit }
42 - { id: 15, class: gr64bit }
43 - { id: 16, class: gr64bit }
44 - { id: 17, class: gr64bit }
45 - { id: 18, class: gr64bit }
46 - { id: 19, class: gr64bit }
48 - { reg: '$r2d', virtual-reg: '%0' }
53 machineFunctionInfo: {}
58 %0:addr64bit = COPY $r2d
59 %1:gr64bit = LG %0, 0, $noreg
60 %2:gr64bit = LG %0, 16, $noreg
61 %3:gr64bit = LG %0, 32, $noreg
62 %4:gr64bit = LG %0, 48, $noreg
63 %5:gr64bit = LG %0, 64, $noreg
64 %6:gr64bit = LG %0, 80, $noreg
65 %7:gr64bit = LG %0, 96, $noreg
66 %8:gr64bit = LG %0, 112, $noreg
67 %9:gr64bit = LG %0, 128, $noreg
69 CallBRASL @foo, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc, implicit $fpc, implicit-def $r2d
70 %10:gr64bit = COPY $r2d
72 CGR %10, %1, implicit-def $cc
73 %12:gr64bit = COPY %10
74 %12:gr64bit = LOCGHI %12, 0, 14, 10, implicit killed $cc
75 CGR %10, %2, implicit-def $cc
76 %12:gr64bit = LOCGHI %12, 1, 14, 10, implicit killed $cc
77 CGR %10, %3, implicit-def $cc
78 %12:gr64bit = LOCGHI %12, 2, 14, 10, implicit killed $cc
79 CGR %10, %4, implicit-def $cc
80 %12:gr64bit = LOCGHI %12, 3, 14, 10, implicit killed $cc
81 CGR %10, %5, implicit-def $cc
82 %12:gr64bit = LOCGHI %12, 4, 14, 10, implicit killed $cc
83 CGR %10, %6, implicit-def $cc
84 %12:gr64bit = LOCGHI %12, 5, 14, 10, implicit killed $cc
85 CGR %10, %7, implicit-def $cc
86 %12:gr64bit = LOCGHI %12, 6, 14, 10, implicit killed $cc
87 CGR %10, %8, implicit-def $cc
88 %12:gr64bit = LOCGHI %12, 7, 14, 10, implicit killed $cc
89 CGR %9, %10, implicit-def $cc
90 %12:gr64bit = LOCGHI %12, 8, 14, 10, implicit killed $cc
98 # CHECK: CLG %10, %stack.0, 0, $noreg, implicit-def $cc :: (load (s64) from %stack.0)
99 # CHECK-NEXT: %12:gr64bit = LOCGHI %12, 8, 14, 12, implicit $cc
103 tracksRegLiveness: true
105 - { id: 0, class: addr64bit }
106 - { id: 1, class: gr64bit }
107 - { id: 2, class: gr64bit }
108 - { id: 3, class: gr64bit }
109 - { id: 4, class: gr64bit }
110 - { id: 5, class: gr64bit }
111 - { id: 6, class: gr64bit }
112 - { id: 7, class: gr64bit }
113 - { id: 8, class: gr64bit }
114 - { id: 9, class: gr64bit }
115 - { id: 10, class: gr64bit }
116 - { id: 11, class: gr64bit }
117 - { id: 12, class: gr64bit }
118 - { id: 13, class: gr64bit }
119 - { id: 14, class: gr64bit }
120 - { id: 15, class: gr64bit }
121 - { id: 16, class: gr64bit }
122 - { id: 17, class: gr64bit }
123 - { id: 18, class: gr64bit }
124 - { id: 19, class: gr64bit }
126 - { reg: '$r2d', virtual-reg: '%0' }
131 machineFunctionInfo: {}
136 %0:addr64bit = COPY $r2d
137 %1:gr64bit = LG %0, 0, $noreg
138 %2:gr64bit = LG %0, 16, $noreg
139 %3:gr64bit = LG %0, 32, $noreg
140 %4:gr64bit = LG %0, 48, $noreg
141 %5:gr64bit = LG %0, 64, $noreg
142 %6:gr64bit = LG %0, 80, $noreg
143 %7:gr64bit = LG %0, 96, $noreg
144 %8:gr64bit = LG %0, 112, $noreg
145 %9:gr64bit = LG %0, 128, $noreg
146 ADJCALLSTACKDOWN 0, 0
147 CallBRASL @foo, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc, implicit $fpc, implicit-def $r2d
148 %10:gr64bit = COPY $r2d
150 CGR %10, %1, implicit-def $cc
151 %12:gr64bit = COPY %10
152 %12:gr64bit = LOCGHI %12, 0, 14, 10, implicit killed $cc
153 CGR %10, %2, implicit-def $cc
154 %12:gr64bit = LOCGHI %12, 1, 14, 10, implicit killed $cc
155 CGR %10, %3, implicit-def $cc
156 %12:gr64bit = LOCGHI %12, 2, 14, 10, implicit killed $cc
157 CGR %10, %4, implicit-def $cc
158 %12:gr64bit = LOCGHI %12, 3, 14, 10, implicit killed $cc
159 CGR %10, %5, implicit-def $cc
160 %12:gr64bit = LOCGHI %12, 4, 14, 10, implicit killed $cc
161 CGR %10, %6, implicit-def $cc
162 %12:gr64bit = LOCGHI %12, 5, 14, 10, implicit killed $cc
163 CGR %10, %7, implicit-def $cc
164 %12:gr64bit = LOCGHI %12, 6, 14, 10, implicit killed $cc
165 CGR %10, %8, implicit-def $cc
166 %12:gr64bit = LOCGHI %12, 7, 14, 10, implicit killed $cc
167 CLGR %9, %10, implicit-def $cc
168 %12:gr64bit = LOCGHI %12, 8, 14, 10, implicit killed $cc
176 # CHECK: C %10, %stack.0, 0, $noreg, implicit-def $cc :: (load (s32) from %stack.0)
177 # CHECK: %12:gr32bit = LOCHIMux %12, 8, 14, 12, implicit $cc
181 tracksRegLiveness: true
183 - { id: 0, class: addr64bit }
184 - { id: 1, class: gr32bit }
185 - { id: 2, class: gr32bit }
186 - { id: 3, class: gr32bit }
187 - { id: 4, class: gr32bit }
188 - { id: 5, class: gr32bit }
189 - { id: 6, class: gr32bit }
190 - { id: 7, class: gr32bit }
191 - { id: 8, class: gr32bit }
192 - { id: 9, class: gr32bit }
193 - { id: 10, class: gr32bit }
194 - { id: 11, class: gr32bit }
195 - { id: 12, class: gr32bit }
196 - { id: 13, class: gr32bit }
197 - { id: 14, class: gr32bit }
198 - { id: 15, class: gr32bit }
199 - { id: 16, class: gr32bit }
200 - { id: 17, class: gr32bit }
201 - { id: 18, class: gr32bit }
202 - { id: 19, class: gr32bit }
204 - { reg: '$r2d', virtual-reg: '%0' }
209 machineFunctionInfo: {}
214 %0:addr64bit = COPY $r2d
215 %1:gr32bit = LMux %0, 0, $noreg
216 %2:gr32bit = LMux %0, 8, $noreg
217 %3:gr32bit = LMux %0, 16, $noreg
218 %4:gr32bit = LMux %0, 24, $noreg
219 %5:gr32bit = LMux %0, 32, $noreg
220 %6:gr32bit = LMux %0, 40, $noreg
221 %7:gr32bit = LMux %0, 48, $noreg
222 %8:gr32bit = LMux %0, 56, $noreg
223 %9:gr32bit = LMux %0, 64, $noreg
224 ADJCALLSTACKDOWN 0, 0
225 CallBRASL @foo, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc, implicit $fpc, implicit-def $r2l
226 %10:gr32bit = COPY $r2l
228 CR %10, %1, implicit-def $cc
229 %12:gr32bit = COPY %10
230 %12:gr32bit = LOCHIMux %12, 0, 14, 10, implicit killed $cc
231 CR %10, %2, implicit-def $cc
232 %12:gr32bit = LOCHIMux %12, 1, 14, 10, implicit killed $cc
233 CR %10, %3, implicit-def $cc
234 %12:gr32bit = LOCHIMux %12, 2, 14, 10, implicit killed $cc
235 CR %10, %4, implicit-def $cc
236 %12:gr32bit = LOCHIMux %12, 3, 14, 10, implicit killed $cc
237 CR %10, %5, implicit-def $cc
238 %12:gr32bit = LOCHIMux %12, 4, 14, 10, implicit killed $cc
239 CR %10, %6, implicit-def $cc
240 %12:gr32bit = LOCHIMux %12, 5, 14, 10, implicit killed $cc
241 CR %10, %7, implicit-def $cc
242 %12:gr32bit = LOCHIMux %12, 6, 14, 10, implicit killed $cc
243 CR %10, %8, implicit-def $cc
244 %12:gr32bit = LOCHIMux %12, 7, 14, 10, implicit killed $cc
245 CR %9, %10, implicit-def $cc
246 %12:gr32bit = LOCHIMux %12, 8, 14, 10, implicit killed $cc
254 # CHECK: CL %10, %stack.0, 0, $noreg, implicit-def $cc :: (load (s32) from %stack.0)
255 # CHECK: %12:gr32bit = LOCHIMux %12, 8, 14, 12, implicit $cc
259 tracksRegLiveness: true
261 - { id: 0, class: addr64bit }
262 - { id: 1, class: gr32bit }
263 - { id: 2, class: gr32bit }
264 - { id: 3, class: gr32bit }
265 - { id: 4, class: gr32bit }
266 - { id: 5, class: gr32bit }
267 - { id: 6, class: gr32bit }
268 - { id: 7, class: gr32bit }
269 - { id: 8, class: gr32bit }
270 - { id: 9, class: gr32bit }
271 - { id: 10, class: gr32bit }
272 - { id: 11, class: gr32bit }
273 - { id: 12, class: gr32bit }
274 - { id: 13, class: gr32bit }
275 - { id: 14, class: gr32bit }
276 - { id: 15, class: gr32bit }
277 - { id: 16, class: gr32bit }
278 - { id: 17, class: gr32bit }
279 - { id: 18, class: gr32bit }
280 - { id: 19, class: gr32bit }
282 - { reg: '$r2d', virtual-reg: '%0' }
287 machineFunctionInfo: {}
292 %0:addr64bit = COPY $r2d
293 %1:gr32bit = LMux %0, 0, $noreg
294 %2:gr32bit = LMux %0, 8, $noreg
295 %3:gr32bit = LMux %0, 16, $noreg
296 %4:gr32bit = LMux %0, 24, $noreg
297 %5:gr32bit = LMux %0, 32, $noreg
298 %6:gr32bit = LMux %0, 40, $noreg
299 %7:gr32bit = LMux %0, 48, $noreg
300 %8:gr32bit = LMux %0, 56, $noreg
301 %9:gr32bit = LMux %0, 64, $noreg
302 ADJCALLSTACKDOWN 0, 0
303 CallBRASL @foo, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc, implicit $fpc, implicit-def $r2l
304 %10:gr32bit = COPY $r2l
306 CR %10, %1, implicit-def $cc
307 %12:gr32bit = COPY %10
308 %12:gr32bit = LOCHIMux %12, 0, 14, 10, implicit killed $cc
309 CR %10, %2, implicit-def $cc
310 %12:gr32bit = LOCHIMux %12, 1, 14, 10, implicit killed $cc
311 CR %10, %3, implicit-def $cc
312 %12:gr32bit = LOCHIMux %12, 2, 14, 10, implicit killed $cc
313 CR %10, %4, implicit-def $cc
314 %12:gr32bit = LOCHIMux %12, 3, 14, 10, implicit killed $cc
315 CR %10, %5, implicit-def $cc
316 %12:gr32bit = LOCHIMux %12, 4, 14, 10, implicit killed $cc
317 CR %10, %6, implicit-def $cc
318 %12:gr32bit = LOCHIMux %12, 5, 14, 10, implicit killed $cc
319 CR %10, %7, implicit-def $cc
320 %12:gr32bit = LOCHIMux %12, 6, 14, 10, implicit killed $cc
321 CR %10, %8, implicit-def $cc
322 %12:gr32bit = LOCHIMux %12, 7, 14, 10, implicit killed $cc
323 CLR %9, %10, implicit-def $cc
324 %12:gr32bit = LOCHIMux %12, 8, 14, 10, implicit killed $cc