1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=aarch64-unknown-unknown -verify-machineinstrs -global-isel-abort=0 -run-pass=legalizer %s -o - | FileCheck %s
6 exposesReturnsTwice: false
10 tracksRegLiveness: true
12 - { id: 0, class: _, preferred-register: '' }
13 - { id: 1, class: _, preferred-register: '' }
14 - { id: 2, class: _, preferred-register: '' }
15 - { id: 3, class: _, preferred-register: '' }
16 - { id: 4, class: _, preferred-register: '' }
17 - { id: 5, class: _, preferred-register: '' }
18 - { id: 6, class: _, preferred-register: '' }
19 - { id: 7, class: _, preferred-register: '' }
20 - { id: 8, class: _, preferred-register: '' }
21 - { id: 9, class: _, preferred-register: '' }
22 - { id: 10, class: _, preferred-register: '' }
25 ; CHECK-LABEL: name: legalize_phi
27 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
28 ; CHECK-NEXT: liveins: $w0
30 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
31 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
32 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
33 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
34 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
35 ; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.1
36 ; CHECK-NEXT: G_BR %bb.2
39 ; CHECK-NEXT: successors: %bb.3(0x80000000)
41 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
42 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
43 ; CHECK-NEXT: G_BR %bb.3
46 ; CHECK-NEXT: successors: %bb.3(0x80000000)
48 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
49 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
52 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.1, [[TRUNC1]](s16), %bb.2
53 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
54 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
55 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
56 ; CHECK-NEXT: $w0 = COPY [[AND]](s32)
57 ; CHECK-NEXT: RET_ReallyLR implicit $w0
59 ; Test that we insert legalization artifacts(Truncs here) into the correct BBs
60 ; while legalizing the G_PHI to s16.
63 successors: %bb.1(0x40000000), %bb.2(0x40000000)
67 %1(s32) = G_CONSTANT i32 0
68 %3(s32) = G_CONSTANT i32 1
69 %6(s32) = G_CONSTANT i32 2
70 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
71 G_BRCOND %2(s1), %bb.1
75 successors: %bb.3(0x80000000)
77 %4(s32) = G_ADD %0, %3
78 %5(s1) = G_TRUNC %4(s32)
82 successors: %bb.3(0x80000000)
84 %7(s32) = G_ADD %0, %6
85 %8(s1) = G_TRUNC %7(s32)
88 %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
89 %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
90 %10(s32) = G_ZEXT %9(s1)
92 RET_ReallyLR implicit $w0
96 name: legalize_phi_ptr
98 exposesReturnsTwice: false
100 regBankSelected: false
102 tracksRegLiveness: true
104 - { id: 0, class: _, preferred-register: '' }
105 - { id: 1, class: _, preferred-register: '' }
106 - { id: 2, class: _, preferred-register: '' }
107 - { id: 3, class: _, preferred-register: '' }
108 - { id: 4, class: _, preferred-register: '' }
109 - { id: 5, class: _, preferred-register: '' }
112 ; CHECK-LABEL: name: legalize_phi_ptr
114 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
115 ; CHECK-NEXT: liveins: $w2, $x0, $x1
117 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
118 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
119 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
120 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
121 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C]]
122 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.1
123 ; CHECK-NEXT: G_BR %bb.2
126 ; CHECK-NEXT: successors: %bb.2(0x80000000)
129 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
130 ; CHECK-NEXT: $x0 = COPY [[PHI]](p0)
131 ; CHECK-NEXT: RET_ReallyLR implicit $x0
134 successors: %bb.2, %bb.3
135 liveins: $w2, $x0, $x1
140 %2(s1) = G_TRUNC %4(s32)
141 G_BRCOND %2(s1), %bb.2
148 %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
150 RET_ReallyLR implicit $x0
154 name: legalize_phi_empty
156 exposesReturnsTwice: false
158 regBankSelected: false
160 tracksRegLiveness: true
162 - { id: 0, class: _, preferred-register: '' }
163 - { id: 1, class: _, preferred-register: '' }
164 - { id: 2, class: _, preferred-register: '' }
165 - { id: 3, class: _, preferred-register: '' }
166 - { id: 4, class: _, preferred-register: '' }
167 - { id: 5, class: _, preferred-register: '' }
168 - { id: 6, class: _, preferred-register: '' }
169 - { id: 7, class: _, preferred-register: '' }
170 - { id: 8, class: _, preferred-register: '' }
171 - { id: 9, class: _, preferred-register: '' }
172 - { id: 10, class: _, preferred-register: '' }
175 ; CHECK-LABEL: name: legalize_phi_empty
177 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
178 ; CHECK-NEXT: liveins: $w0
180 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
181 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
182 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
183 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
184 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
185 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
186 ; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.1
187 ; CHECK-NEXT: G_BR %bb.2
190 ; CHECK-NEXT: successors: %bb.3(0x80000000)
192 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
193 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
194 ; CHECK-NEXT: G_BR %bb.3
197 ; CHECK-NEXT: successors: %bb.3(0x80000000)
199 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
202 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.1, [[TRUNC1]](s16), %bb.2
203 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
204 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
205 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
206 ; CHECK-NEXT: $w0 = COPY [[AND]](s32)
207 ; CHECK-NEXT: RET_ReallyLR implicit $w0
209 successors: %bb.1(0x40000000), %bb.2(0x40000000)
211 ; Test that we properly legalize a phi with a predecessor that's empty
217 %1(s32) = G_CONSTANT i32 0
218 %3(s32) = G_CONSTANT i32 3
219 %6(s32) = G_CONSTANT i32 1
220 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
221 %4(s32) = G_ADD %0, %3
222 %5(s1) = G_TRUNC %4(s32)
223 G_BRCOND %2(s1), %bb.1
227 successors: %bb.3(0x80000000)
229 %7(s32) = G_ADD %0, %6
230 %8(s1) = G_TRUNC %7(s32)
234 successors: %bb.3(0x80000000)
238 %9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
239 %10(s32) = G_ZEXT %9(s1)
241 RET_ReallyLR implicit $w0
245 name: legalize_phi_loop
247 exposesReturnsTwice: false
249 regBankSelected: false
251 tracksRegLiveness: true
253 - { id: 0, class: _, preferred-register: '' }
254 - { id: 1, class: _, preferred-register: '' }
255 - { id: 2, class: _, preferred-register: '' }
256 - { id: 3, class: _, preferred-register: '' }
257 - { id: 4, class: _, preferred-register: '' }
258 - { id: 5, class: _, preferred-register: '' }
259 - { id: 6, class: _, preferred-register: '' }
260 - { id: 7, class: _, preferred-register: '' }
263 ; CHECK-LABEL: name: legalize_phi_loop
265 ; CHECK-NEXT: successors: %bb.1(0x80000000)
266 ; CHECK-NEXT: liveins: $w0
268 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
269 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
272 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
274 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %14(s16), %bb.1
275 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
276 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
277 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[C1]]
278 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
279 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C2]]
280 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
281 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
282 ; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.1
285 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
286 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C3]]
287 ; CHECK-NEXT: $w0 = COPY [[AND1]](s32)
288 ; CHECK-NEXT: RET_ReallyLR implicit $w0
290 successors: %bb.1(0x80000000)
292 ; Test that we properly legalize a phi that uses a value from the same BB
295 %2(s8) = G_CONSTANT i8 1
296 %7(s8) = G_CONSTANT i8 0
299 successors: %bb.1(0x40000000), %bb.3(0x40000000)
301 %1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
302 %3(s8) = G_ADD %1, %2
303 %4(s32) = G_ZEXT %3(s8)
304 %5(s1) = G_ICMP intpred(ugt), %4(s32), %0
305 G_BRCOND %5(s1), %bb.1
308 %6(s32) = G_ZEXT %3(s8)
310 RET_ReallyLR implicit $w0
314 name: legalize_phi_cycle
316 exposesReturnsTwice: false
318 regBankSelected: false
320 tracksRegLiveness: true
322 - { id: 0, class: _, preferred-register: '' }
323 - { id: 1, class: _, preferred-register: '' }
324 - { id: 2, class: _, preferred-register: '' }
325 - { id: 3, class: _, preferred-register: '' }
326 - { id: 4, class: _, preferred-register: '' }
329 ; CHECK-LABEL: name: legalize_phi_cycle
331 ; CHECK-NEXT: successors: %bb.1(0x80000000)
332 ; CHECK-NEXT: liveins: $w0
334 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
335 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
338 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
340 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, [[PHI]](s16), %bb.1
341 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
342 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
343 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
344 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
345 ; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.1
348 ; CHECK-NEXT: $w0 = COPY [[AND]](s32)
349 ; CHECK-NEXT: RET_ReallyLR implicit $w0
351 successors: %bb.1(0x80000000)
353 ; Test that we properly legalize a phi that uses itself
357 %4(s8) = G_CONSTANT i8 0
360 successors: %bb.1(0x40000000), %bb.3(0x40000000)
362 %1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
363 %2(s32) = G_ZEXT %1(s8)
364 %3(s1) = G_ICMP intpred(ugt), %2(s32), %0
365 G_BRCOND %3(s1), %bb.1
369 RET_ReallyLR implicit $w0
373 name: legalize_phi_same_bb
375 exposesReturnsTwice: false
377 regBankSelected: false
379 tracksRegLiveness: true
381 - { id: 0, class: _, preferred-register: '' }
382 - { id: 1, class: _, preferred-register: '' }
383 - { id: 2, class: _, preferred-register: '' }
384 - { id: 3, class: _, preferred-register: '' }
385 - { id: 4, class: _, preferred-register: '' }
386 - { id: 5, class: _, preferred-register: '' }
387 - { id: 6, class: _, preferred-register: '' }
388 - { id: 7, class: _, preferred-register: '' }
389 - { id: 8, class: _, preferred-register: '' }
390 - { id: 9, class: _, preferred-register: '' }
391 - { id: 10, class: _, preferred-register: '' }
392 - { id: 11, class: _, preferred-register: '' }
393 - { id: 12, class: _, preferred-register: '' }
394 - { id: 13, class: _, preferred-register: '' }
395 - { id: 14, class: _, preferred-register: '' }
398 ; CHECK-LABEL: name: legalize_phi_same_bb
400 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
401 ; CHECK-NEXT: liveins: $w0
403 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
404 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
405 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
406 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
407 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
408 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
409 ; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.1
410 ; CHECK-NEXT: G_BR %bb.2
413 ; CHECK-NEXT: successors: %bb.3(0x80000000)
415 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
416 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
417 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
418 ; CHECK-NEXT: G_BR %bb.3
421 ; CHECK-NEXT: successors: %bb.3(0x80000000)
423 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 42
424 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
427 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
428 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.1, [[C3]](s16), %bb.2
429 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
430 ; CHECK-NEXT: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
431 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
432 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
433 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C4]]
434 ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
435 ; CHECK-NEXT: $w0 = COPY [[ADD2]](s32)
436 ; CHECK-NEXT: RET_ReallyLR implicit $w0
438 successors: %bb.1(0x40000000), %bb.2(0x40000000)
440 ; Make sure that we correctly insert the new legalized G_PHI at the
441 ; correct location (ie make sure G_PHIs are the first insts in the BB).
447 %1(s32) = G_CONSTANT i32 0
448 %3(s32) = G_CONSTANT i32 3
449 %6(s32) = G_CONSTANT i32 1
450 %14(s8) = G_CONSTANT i8 42
451 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
452 %4(s32) = G_ADD %0, %3
453 %5(s8) = G_TRUNC %4(s32)
454 G_BRCOND %2(s1), %bb.1
458 successors: %bb.3(0x80000000)
460 %7(s32) = G_ADD %0, %6
461 %8(s8) = G_TRUNC %7(s32)
465 successors: %bb.3(0x80000000)
469 %9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
470 %10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
471 %11(s32) = G_ZEXT %9(s8)
472 %12(s32) = G_ZEXT %10(s8)
473 %13(s32) = G_ADD %11, %12
475 RET_ReallyLR implicit $w0
479 name: legalize_phi_diff_bb
481 exposesReturnsTwice: false
483 regBankSelected: false
485 tracksRegLiveness: true
487 - { id: 0, class: _, preferred-register: '' }
488 - { id: 1, class: _, preferred-register: '' }
489 - { id: 2, class: _, preferred-register: '' }
490 - { id: 3, class: _, preferred-register: '' }
491 - { id: 4, class: _, preferred-register: '' }
492 - { id: 5, class: _, preferred-register: '' }
493 - { id: 6, class: _, preferred-register: '' }
494 - { id: 7, class: _, preferred-register: '' }
495 - { id: 8, class: _, preferred-register: '' }
496 - { id: 9, class: _, preferred-register: '' }
497 - { id: 10, class: _, preferred-register: '' }
498 - { id: 11, class: _, preferred-register: '' }
499 - { id: 12, class: _, preferred-register: '' }
500 - { id: 13, class: _, preferred-register: '' }
501 - { id: 14, class: _, preferred-register: '' }
502 - { id: 15, class: _, preferred-register: '' }
505 ; CHECK-LABEL: name: legalize_phi_diff_bb
507 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
508 ; CHECK-NEXT: liveins: $w0, $w1
510 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
511 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
512 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
513 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
514 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
515 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
516 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
517 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
518 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
519 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
520 ; CHECK-NEXT: G_BRCOND [[ICMP]](s32), %bb.1
521 ; CHECK-NEXT: G_BR %bb.2
524 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
526 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.0, %22(s16), %bb.1
527 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
528 ; CHECK-NEXT: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
529 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
530 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
531 ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
532 ; CHECK-NEXT: [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 43
533 ; CHECK-NEXT: G_BRCOND [[ICMP1]](s32), %bb.2
534 ; CHECK-NEXT: G_BR %bb.1
537 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[PHI]](s16), %bb.1, [[TRUNC]](s16), %bb.0
538 ; CHECK-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
539 ; CHECK-NEXT: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
540 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
541 ; CHECK-NEXT: $w0 = COPY [[AND1]](s32)
542 ; CHECK-NEXT: RET_ReallyLR implicit $w0
544 successors: %bb.1(0x40000000), %bb.3(0x40000000)
546 ; Make sure that we correctly legalize PHIs sharing common defs
553 %2(s32) = G_CONSTANT i32 0
554 %4(s32) = G_CONSTANT i32 3
555 %9(s32) = G_CONSTANT i32 1
556 %11(s32) = G_CONSTANT i32 44
557 %15(s8) = G_CONSTANT i8 43
558 %3(s1) = G_ICMP intpred(ugt), %0(s32), %2
559 %5(s32) = G_ADD %0, %4
560 %6(s8) = G_TRUNC %5(s32)
561 G_BRCOND %3(s1), %bb.1
565 successors: %bb.3(0x40000000), %bb.1(0x40000000)
567 %7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
568 %8(s32) = G_ZEXT %7(s8)
569 %10(s32) = G_ADD %8, %9
570 %12(s1) = G_ICMP intpred(ugt), %10(s32), %11
571 G_BRCOND %12(s1), %bb.3
575 %13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
576 %14(s32) = G_ZEXT %13(s8)
578 RET_ReallyLR implicit $w0
582 name: legalize_phi_check_insertpt
584 exposesReturnsTwice: false
586 regBankSelected: false
588 tracksRegLiveness: true
590 ; CHECK-LABEL: name: legalize_phi_check_insertpt
592 ; CHECK-NEXT: successors: %bb.1(0x80000000)
593 ; CHECK-NEXT: liveins: $x0, $x1
595 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
596 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
597 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
598 ; CHECK-NEXT: G_BR %bb.1
601 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
602 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
603 ; CHECK-NEXT: [[PHI2:%[0-9]+]]:_(s64) = G_PHI [[COPY]](s64), %bb.0
604 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[PHI]](s64), [[PHI1]](s64)
605 ; CHECK-NEXT: G_STORE [[MV]](s128), [[COPY1]](p0) :: (store (s128))
606 ; CHECK-NEXT: G_STORE [[PHI2]](s64), [[COPY1]](p0) :: (store (s64))
607 ; CHECK-NEXT: RET_ReallyLR
608 ; Check that the G_MERGE here gets inserted after all the PHIs.
610 successors: %bb.1(0x40000000)
615 %2:_(s128) = G_IMPLICIT_DEF
619 %3:_(s128) = G_PHI %2(s128), %bb.0
620 %4:_(s64) = G_PHI %0(s64), %bb.0
621 G_STORE %3(s128), %1(p0) :: (store (s128))
622 G_STORE %4(s64), %1(p0) :: (store (s64))
627 name: legalize_phi_vector
628 tracksRegLiveness: true
630 ; CHECK-LABEL: name: legalize_phi_vector
632 ; CHECK-NEXT: successors: %bb.1(0x80000000)
633 ; CHECK-NEXT: liveins: $q0, $x1
635 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0
636 ; CHECK-NEXT: G_BR %bb.1
639 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(<16 x s8>) = G_PHI [[COPY]](<16 x s8>), %bb.0
640 ; CHECK-NEXT: $q0 = COPY [[PHI]](<16 x s8>)
641 ; CHECK-NEXT: RET_ReallyLR
646 %0:_(<16 x s8>) = COPY $q0
650 %3:_(<16 x s8>) = G_PHI %0(<16 x s8>), %bb.0
651 $q0 = COPY %3(<16 x s8>)
656 tracksRegLiveness: true
659 ; CHECK-LABEL: name: s88
661 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
662 ; CHECK-NEXT: liveins: $x0
664 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
665 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
666 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[DEF]], [[C]]
667 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.1
668 ; CHECK-NEXT: G_BR %bb.2
671 ; CHECK-NEXT: successors: %bb.3(0x80000000)
673 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
674 ; CHECK-NEXT: G_BR %bb.3
677 ; CHECK-NEXT: successors: %bb.3(0x80000000)
679 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
682 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF1]](s64), %bb.1, [[DEF2]](s64), %bb.2
683 ; CHECK-NEXT: $x0 = COPY [[PHI]](s64)
684 ; CHECK-NEXT: RET_ReallyLR implicit $x0
686 successors: %bb.1(0x40000000), %bb.2(0x40000000)
688 %cond:_(s1) = G_IMPLICIT_DEF
689 G_BRCOND %cond(s1), %bb.1
692 successors: %bb.3(0x80000000)
693 %imp_1:_(s88) = G_IMPLICIT_DEF
696 successors: %bb.3(0x80000000)
697 %imp_2:_(s88) = G_IMPLICIT_DEF
699 %phi:_(s88) = G_PHI %imp_1:_(s88), %bb.1, %imp_2:_(s88), %bb.2
700 %trunc:_(s64) = G_TRUNC %phi
702 RET_ReallyLR implicit $x0
707 tracksRegLiveness: true
709 ; CHECK-LABEL: name: v4s64
711 ; CHECK-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000)
712 ; CHECK-NEXT: liveins: $x0, $x1
714 ; CHECK-NEXT: %ptr1:_(p0) = COPY $x1
715 ; CHECK-NEXT: %ptr2:_(p0) = COPY $x0
716 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr1(p0) :: (load (<2 x s64>), align 32)
717 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
718 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr1, [[C]](s64)
719 ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD]](p0) :: (load (<2 x s64>) from unknown-address + 16)
720 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
721 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
722 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[DEF]], [[C1]]
723 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.2
724 ; CHECK-NEXT: G_BR %bb.1
727 ; CHECK-NEXT: successors: %bb.2(0x80000000)
729 ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr2(p0) :: (load (<2 x s64>), align 32)
730 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
731 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr2, [[C2]](s64)
732 ; CHECK-NEXT: [[LOAD3:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD1]](p0) :: (load (<2 x s64>) from unknown-address + 16)
735 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(<2 x s64>) = G_PHI [[LOAD2]](<2 x s64>), %bb.1, [[LOAD]](<2 x s64>), %bb.0
736 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:_(<2 x s64>) = G_PHI [[LOAD3]](<2 x s64>), %bb.1, [[LOAD1]](<2 x s64>), %bb.0
737 ; CHECK-NEXT: $q0 = COPY [[PHI]](<2 x s64>)
738 ; CHECK-NEXT: $q1 = COPY [[PHI1]](<2 x s64>)
739 ; CHECK-NEXT: RET_ReallyLR implicit $q0, implicit $q1
741 successors: %bb.1(0x50000000), %bb.2(0x30000000)
744 %ptr1:_(p0) = COPY $x1
745 %ptr2:_(p0) = COPY $x0
746 %cond:_(s1) = G_IMPLICIT_DEF
747 %val_1:_(<4 x s64>) = G_LOAD %ptr1(p0) :: (load (<4 x s64>))
748 G_BRCOND %cond(s1), %bb.2
751 %val_2:_(<4 x s64>) = G_LOAD %ptr2(p0) :: (load (<4 x s64>))
753 %phi:_(<4 x s64>) = G_PHI %val_2(<4 x s64>), %bb.1, %val_1(<4 x s64>), %bb.0
754 %unmerge_1:_(<2 x s64>), %unmerge_2:_(<2 x s64>) = G_UNMERGE_VALUES %phi(<4 x s64>)
755 $q0 = COPY %unmerge_1(<2 x s64>)
756 $q1 = COPY %unmerge_2(<2 x s64>)
757 RET_ReallyLR implicit $q0, implicit $q1
762 tracksRegLiveness: true
764 ; CHECK-LABEL: name: v8s32
766 ; CHECK-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000)
767 ; CHECK-NEXT: liveins: $x0, $x1
769 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<4 x s32>) = G_IMPLICIT_DEF
770 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
771 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
772 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[DEF1]], [[C]]
773 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.2
774 ; CHECK-NEXT: G_BR %bb.1
777 ; CHECK-NEXT: successors: %bb.2(0x80000000)
779 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:_(<4 x s32>) = G_IMPLICIT_DEF
782 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(<4 x s32>) = G_PHI [[DEF2]](<4 x s32>), %bb.1, [[DEF]](<4 x s32>), %bb.0
783 ; CHECK-NEXT: %one:_(s64) = G_CONSTANT i64 1
784 ; CHECK-NEXT: %extract:_(s32) = G_EXTRACT_VECTOR_ELT [[PHI]](<4 x s32>), %one(s64)
785 ; CHECK-NEXT: $w0 = COPY %extract(s32)
786 ; CHECK-NEXT: RET_ReallyLR implicit $w0
788 successors: %bb.1(0x50000000), %bb.2(0x30000000)
790 %cond:_(s1) = G_IMPLICIT_DEF
791 %val_1:_(<8 x s32>) = G_IMPLICIT_DEF
792 G_BRCOND %cond(s1), %bb.2
795 %val_2:_(<8 x s32>) = G_IMPLICIT_DEF
797 %phi:_(<8 x s32>) = G_PHI %val_2(<8 x s32>), %bb.1, %val_1(<8 x s32>), %bb.0
798 %one:_(s64) = G_CONSTANT i64 1
799 %extract:_(s32) = G_EXTRACT_VECTOR_ELT %phi(<8 x s32>), %one(s64)
801 RET_ReallyLR implicit $w0
806 tracksRegLiveness: true
808 ; CHECK-LABEL: name: v16s16
810 ; CHECK-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000)
811 ; CHECK-NEXT: liveins: $x0, $x1
813 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<8 x s16>) = G_IMPLICIT_DEF
814 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
815 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
816 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[DEF1]], [[C]]
817 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.2
818 ; CHECK-NEXT: G_BR %bb.1
821 ; CHECK-NEXT: successors: %bb.2(0x80000000)
823 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:_(<8 x s16>) = G_IMPLICIT_DEF
826 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(<8 x s16>) = G_PHI [[DEF2]](<8 x s16>), %bb.1, [[DEF]](<8 x s16>), %bb.0
827 ; CHECK-NEXT: %one:_(s64) = G_CONSTANT i64 1
828 ; CHECK-NEXT: %extract:_(s16) = G_EXTRACT_VECTOR_ELT [[PHI]](<8 x s16>), %one(s64)
829 ; CHECK-NEXT: $h0 = COPY %extract(s16)
830 ; CHECK-NEXT: RET_ReallyLR implicit $h0
832 successors: %bb.1(0x50000000), %bb.2(0x30000000)
834 %cond:_(s1) = G_IMPLICIT_DEF
835 %val_1:_(<16 x s16>) = G_IMPLICIT_DEF
836 G_BRCOND %cond(s1), %bb.2
839 %val_2:_(<16 x s16>) = G_IMPLICIT_DEF
841 %phi:_(<16 x s16>) = G_PHI %val_2(<16 x s16>), %bb.1, %val_1(<16 x s16>), %bb.0
842 %one:_(s64) = G_CONSTANT i64 1
843 %extract:_(s16) = G_EXTRACT_VECTOR_ELT %phi(<16 x s16>), %one(s64)
845 RET_ReallyLR implicit $h0
850 tracksRegLiveness: true
852 ; CHECK-LABEL: name: v32s8
854 ; CHECK-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000)
855 ; CHECK-NEXT: liveins: $x0, $x1
857 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<16 x s8>) = G_IMPLICIT_DEF
858 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
859 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
860 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[DEF1]], [[C]]
861 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.2
862 ; CHECK-NEXT: G_BR %bb.1
865 ; CHECK-NEXT: successors: %bb.2(0x80000000)
867 ; CHECK-NEXT: [[DEF2:%[0-9]+]]:_(<16 x s8>) = G_IMPLICIT_DEF
870 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(<16 x s8>) = G_PHI [[DEF2]](<16 x s8>), %bb.1, [[DEF]](<16 x s8>), %bb.0
871 ; CHECK-NEXT: %one:_(s64) = G_CONSTANT i64 1
872 ; CHECK-NEXT: %extract:_(s8) = G_EXTRACT_VECTOR_ELT [[PHI]](<16 x s8>), %one(s64)
873 ; CHECK-NEXT: $b0 = COPY %extract(s8)
874 ; CHECK-NEXT: RET_ReallyLR implicit $b0
876 successors: %bb.1(0x50000000), %bb.2(0x30000000)
878 %cond:_(s1) = G_IMPLICIT_DEF
879 %val_1:_(<32 x s8>) = G_IMPLICIT_DEF
880 G_BRCOND %cond(s1), %bb.2
883 %val_2:_(<32 x s8>) = G_IMPLICIT_DEF
885 %phi:_(<32 x s8>) = G_PHI %val_2(<32 x s8>), %bb.1, %val_1(<32 x s8>), %bb.0
886 %one:_(s64) = G_CONSTANT i64 1
887 %extract:_(s8) = G_EXTRACT_VECTOR_ELT %phi(<32 x s8>), %one(s64)
889 RET_ReallyLR implicit $b0
894 tracksRegLiveness: true
896 ; CHECK-LABEL: name: v4p0
898 ; CHECK-NEXT: successors: %bb.1(0x50000000), %bb.2(0x30000000)
899 ; CHECK-NEXT: liveins: $x0, $x1
901 ; CHECK-NEXT: %ptr1:_(p0) = COPY $x1
902 ; CHECK-NEXT: %ptr2:_(p0) = COPY $x0
903 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr1(p0) :: (load (<2 x s64>), align 32)
904 ; CHECK-NEXT: [[BITCAST:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD]](<2 x s64>)
905 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
906 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr1, [[C]](s64)
907 ; CHECK-NEXT: [[LOAD1:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD]](p0) :: (load (<2 x s64>) from unknown-address + 16)
908 ; CHECK-NEXT: [[BITCAST1:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD1]](<2 x s64>)
909 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
910 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
911 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[DEF]], [[C1]]
912 ; CHECK-NEXT: G_BRCOND [[AND]](s32), %bb.2
913 ; CHECK-NEXT: G_BR %bb.1
916 ; CHECK-NEXT: successors: %bb.2(0x80000000)
918 ; CHECK-NEXT: [[LOAD2:%[0-9]+]]:_(<2 x s64>) = G_LOAD %ptr2(p0) :: (load (<2 x s64>), align 32)
919 ; CHECK-NEXT: [[BITCAST2:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD2]](<2 x s64>)
920 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
921 ; CHECK-NEXT: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD %ptr2, [[C2]](s64)
922 ; CHECK-NEXT: [[LOAD3:%[0-9]+]]:_(<2 x s64>) = G_LOAD [[PTR_ADD1]](p0) :: (load (<2 x s64>) from unknown-address + 16)
923 ; CHECK-NEXT: [[BITCAST3:%[0-9]+]]:_(<2 x p0>) = G_BITCAST [[LOAD3]](<2 x s64>)
926 ; CHECK-NEXT: [[PHI:%[0-9]+]]:_(<2 x p0>) = G_PHI [[BITCAST2]](<2 x p0>), %bb.1, [[BITCAST]](<2 x p0>), %bb.0
927 ; CHECK-NEXT: [[PHI1:%[0-9]+]]:_(<2 x p0>) = G_PHI [[BITCAST3]](<2 x p0>), %bb.1, [[BITCAST1]](<2 x p0>), %bb.0
928 ; CHECK-NEXT: $q0 = COPY [[PHI]](<2 x p0>)
929 ; CHECK-NEXT: $q1 = COPY [[PHI1]](<2 x p0>)
930 ; CHECK-NEXT: RET_ReallyLR implicit $q0, implicit $q1
932 successors: %bb.1(0x50000000), %bb.2(0x30000000)
935 %ptr1:_(p0) = COPY $x1
936 %ptr2:_(p0) = COPY $x0
937 %cond:_(s1) = G_IMPLICIT_DEF
938 %val_1:_(<4 x p0>) = G_LOAD %ptr1(p0) :: (load (<4 x p0>))
939 G_BRCOND %cond(s1), %bb.2
942 %val_2:_(<4 x p0>) = G_LOAD %ptr2(p0) :: (load (<4 x p0>))
944 %phi:_(<4 x p0>) = G_PHI %val_2(<4 x p0>), %bb.1, %val_1(<4 x p0>), %bb.0
945 %unmerge_1:_(<2 x p0>), %unmerge_2:_(<2 x p0>) = G_UNMERGE_VALUES %phi(<4 x p0>)
946 $q0 = COPY %unmerge_1(<2 x p0>)
947 $q1 = COPY %unmerge_2(<2 x p0>)
948 RET_ReallyLR implicit $q0, implicit $q1