1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=aarch64-unknown-unknown -verify-machineinstrs -run-pass=legalizer %s -o - | FileCheck %s
4 ; ModuleID = '/tmp/test.ll'
5 source_filename = "/tmp/test.ll"
6 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7 target triple = "aarch64-unknown-unknown"
9 define i32 @legalize_phi(i32 %argc) {
14 define i64* @legalize_phi_ptr(i64* %a, i64* %b, i1 %cond) {
19 define i32 @legalize_phi_empty(i32 %argc) {
24 define i32 @legalize_phi_loop(i32 %argc) {
29 define i32 @legalize_phi_cycle(i32 %argc) {
33 define i32 @legalize_phi_same_bb(i32 %argc) {
38 define i32 @legalize_phi_diff_bb(i32 %argc, i32 %argc2) {
43 define i32 @legalize_phi_check_insertpt(i64 %a) {
52 exposesReturnsTwice: false
54 regBankSelected: false
56 tracksRegLiveness: true
58 - { id: 0, class: _, preferred-register: '' }
59 - { id: 1, class: _, preferred-register: '' }
60 - { id: 2, class: _, preferred-register: '' }
61 - { id: 3, class: _, preferred-register: '' }
62 - { id: 4, class: _, preferred-register: '' }
63 - { id: 5, class: _, preferred-register: '' }
64 - { id: 6, class: _, preferred-register: '' }
65 - { id: 7, class: _, preferred-register: '' }
66 - { id: 8, class: _, preferred-register: '' }
67 - { id: 9, class: _, preferred-register: '' }
68 - { id: 10, class: _, preferred-register: '' }
71 ; CHECK-LABEL: name: legalize_phi
73 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
75 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
76 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
77 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
78 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
79 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
80 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
81 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
84 ; CHECK: successors: %bb.3(0x80000000)
85 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
86 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
89 ; CHECK: successors: %bb.3(0x80000000)
90 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
91 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
93 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
94 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
95 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
96 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
97 ; CHECK: $w0 = COPY [[AND]](s32)
98 ; CHECK: RET_ReallyLR implicit $w0
100 ; Test that we insert legalization artifacts(Truncs here) into the correct BBs
101 ; while legalizing the G_PHI to s16.
104 successors: %bb.1(0x40000000), %bb.2(0x40000000)
108 %1(s32) = G_CONSTANT i32 0
109 %3(s32) = G_CONSTANT i32 1
110 %6(s32) = G_CONSTANT i32 2
111 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
112 G_BRCOND %2(s1), %bb.1
116 successors: %bb.3(0x80000000)
118 %4(s32) = G_ADD %0, %3
119 %5(s1) = G_TRUNC %4(s32)
123 successors: %bb.3(0x80000000)
125 %7(s32) = G_ADD %0, %6
126 %8(s1) = G_TRUNC %7(s32)
129 %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
130 %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
131 %10(s32) = G_ZEXT %9(s1)
133 RET_ReallyLR implicit $w0
137 name: legalize_phi_ptr
139 exposesReturnsTwice: false
141 regBankSelected: false
143 tracksRegLiveness: true
145 - { id: 0, class: _, preferred-register: '' }
146 - { id: 1, class: _, preferred-register: '' }
147 - { id: 2, class: _, preferred-register: '' }
148 - { id: 3, class: _, preferred-register: '' }
149 - { id: 4, class: _, preferred-register: '' }
150 - { id: 5, class: _, preferred-register: '' }
153 ; CHECK-LABEL: name: legalize_phi_ptr
155 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
156 ; CHECK: liveins: $w2, $x0, $x1
157 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
158 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
159 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
160 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32)
161 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
164 ; CHECK: successors: %bb.2(0x80000000)
166 ; CHECK: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
167 ; CHECK: $x0 = COPY [[PHI]](p0)
168 ; CHECK: RET_ReallyLR implicit $x0
171 successors: %bb.2, %bb.3
172 liveins: $w2, $x0, $x1
177 %2(s1) = G_TRUNC %4(s32)
178 G_BRCOND %2(s1), %bb.2
185 %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
187 RET_ReallyLR implicit $x0
191 name: legalize_phi_empty
193 exposesReturnsTwice: false
195 regBankSelected: false
197 tracksRegLiveness: true
199 - { id: 0, class: _, preferred-register: '' }
200 - { id: 1, class: _, preferred-register: '' }
201 - { id: 2, class: _, preferred-register: '' }
202 - { id: 3, class: _, preferred-register: '' }
203 - { id: 4, class: _, preferred-register: '' }
204 - { id: 5, class: _, preferred-register: '' }
205 - { id: 6, class: _, preferred-register: '' }
206 - { id: 7, class: _, preferred-register: '' }
207 - { id: 8, class: _, preferred-register: '' }
208 - { id: 9, class: _, preferred-register: '' }
209 - { id: 10, class: _, preferred-register: '' }
212 ; CHECK-LABEL: name: legalize_phi_empty
214 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
215 ; CHECK: liveins: $w0
216 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
217 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
218 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
219 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
220 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
221 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
222 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
223 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
226 ; CHECK: successors: %bb.3(0x80000000)
227 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
228 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
231 ; CHECK: successors: %bb.3(0x80000000)
232 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
234 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
235 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
236 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
237 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
238 ; CHECK: $w0 = COPY [[AND]](s32)
239 ; CHECK: RET_ReallyLR implicit $w0
241 successors: %bb.1(0x40000000), %bb.2(0x40000000)
243 ; Test that we properly legalize a phi with a predecessor that's empty
249 %1(s32) = G_CONSTANT i32 0
250 %3(s32) = G_CONSTANT i32 3
251 %6(s32) = G_CONSTANT i32 1
252 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
253 %4(s32) = G_ADD %0, %3
254 %5(s1) = G_TRUNC %4(s32)
255 G_BRCOND %2(s1), %bb.1
259 successors: %bb.3(0x80000000)
261 %7(s32) = G_ADD %0, %6
262 %8(s1) = G_TRUNC %7(s32)
266 successors: %bb.3(0x80000000)
270 %9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
271 %10(s32) = G_ZEXT %9(s1)
273 RET_ReallyLR implicit $w0
277 name: legalize_phi_loop
279 exposesReturnsTwice: false
281 regBankSelected: false
283 tracksRegLiveness: true
285 - { id: 0, class: _, preferred-register: '' }
286 - { id: 1, class: _, preferred-register: '' }
287 - { id: 2, class: _, preferred-register: '' }
288 - { id: 3, class: _, preferred-register: '' }
289 - { id: 4, class: _, preferred-register: '' }
290 - { id: 5, class: _, preferred-register: '' }
291 - { id: 6, class: _, preferred-register: '' }
292 - { id: 7, class: _, preferred-register: '' }
295 ; CHECK-LABEL: name: legalize_phi_loop
297 ; CHECK: successors: %bb.1(0x80000000)
298 ; CHECK: liveins: $w0
299 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
300 ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
302 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
303 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %13(s16), %bb.1
304 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
305 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
306 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[C1]]
307 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
308 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
309 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
310 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
311 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
312 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
313 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
315 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
316 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
317 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C3]]
318 ; CHECK: $w0 = COPY [[AND1]](s32)
319 ; CHECK: RET_ReallyLR implicit $w0
321 successors: %bb.1(0x80000000)
323 ; Test that we properly legalize a phi that uses a value from the same BB
326 %2(s8) = G_CONSTANT i8 1
327 %7(s8) = G_CONSTANT i8 0
330 successors: %bb.1(0x40000000), %bb.3(0x40000000)
332 %1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
333 %3(s8) = G_ADD %1, %2
334 %4(s32) = G_ZEXT %3(s8)
335 %5(s1) = G_ICMP intpred(ugt), %4(s32), %0
336 G_BRCOND %5(s1), %bb.1
339 %6(s32) = G_ZEXT %3(s8)
341 RET_ReallyLR implicit $w0
345 name: legalize_phi_cycle
347 exposesReturnsTwice: false
349 regBankSelected: false
351 tracksRegLiveness: true
353 - { id: 0, class: _, preferred-register: '' }
354 - { id: 1, class: _, preferred-register: '' }
355 - { id: 2, class: _, preferred-register: '' }
356 - { id: 3, class: _, preferred-register: '' }
357 - { id: 4, class: _, preferred-register: '' }
360 ; CHECK-LABEL: name: legalize_phi_cycle
362 ; CHECK: successors: %bb.1(0x80000000)
363 ; CHECK: liveins: $w0
364 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
365 ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
367 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
368 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %7(s16), %bb.1
369 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
370 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
371 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
372 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
373 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
374 ; CHECK: [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
375 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
377 ; CHECK: $w0 = COPY [[AND]](s32)
378 ; CHECK: RET_ReallyLR implicit $w0
380 successors: %bb.1(0x80000000)
382 ; Test that we properly legalize a phi that uses itself
386 %4(s8) = G_CONSTANT i8 0
389 successors: %bb.1(0x40000000), %bb.3(0x40000000)
391 %1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
392 %2(s32) = G_ZEXT %1(s8)
393 %3(s1) = G_ICMP intpred(ugt), %2(s32), %0
394 G_BRCOND %3(s1), %bb.1
398 RET_ReallyLR implicit $w0
402 name: legalize_phi_same_bb
404 exposesReturnsTwice: false
406 regBankSelected: false
408 tracksRegLiveness: true
410 - { id: 0, class: _, preferred-register: '' }
411 - { id: 1, class: _, preferred-register: '' }
412 - { id: 2, class: _, preferred-register: '' }
413 - { id: 3, class: _, preferred-register: '' }
414 - { id: 4, class: _, preferred-register: '' }
415 - { id: 5, class: _, preferred-register: '' }
416 - { id: 6, class: _, preferred-register: '' }
417 - { id: 7, class: _, preferred-register: '' }
418 - { id: 8, class: _, preferred-register: '' }
419 - { id: 9, class: _, preferred-register: '' }
420 - { id: 10, class: _, preferred-register: '' }
421 - { id: 11, class: _, preferred-register: '' }
422 - { id: 12, class: _, preferred-register: '' }
423 - { id: 13, class: _, preferred-register: '' }
424 - { id: 14, class: _, preferred-register: '' }
427 ; CHECK-LABEL: name: legalize_phi_same_bb
429 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
430 ; CHECK: liveins: $w0
431 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
432 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
433 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
434 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
435 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
436 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
437 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
438 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
441 ; CHECK: successors: %bb.3(0x80000000)
442 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
443 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
444 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
447 ; CHECK: successors: %bb.3(0x80000000)
448 ; CHECK: [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 42
449 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
451 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC3]](s16), %bb.2
452 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[C3]](s16), %bb.2
453 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
454 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
455 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
456 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
457 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C4]]
458 ; CHECK: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
459 ; CHECK: $w0 = COPY [[ADD2]](s32)
460 ; CHECK: RET_ReallyLR implicit $w0
462 successors: %bb.1(0x40000000), %bb.2(0x40000000)
464 ; Make sure that we correctly insert the new legalized G_PHI at the
465 ; correct location (ie make sure G_PHIs are the first insts in the BB).
471 %1(s32) = G_CONSTANT i32 0
472 %3(s32) = G_CONSTANT i32 3
473 %6(s32) = G_CONSTANT i32 1
474 %14(s8) = G_CONSTANT i8 42
475 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
476 %4(s32) = G_ADD %0, %3
477 %5(s8) = G_TRUNC %4(s32)
478 G_BRCOND %2(s1), %bb.1
482 successors: %bb.3(0x80000000)
484 %7(s32) = G_ADD %0, %6
485 %8(s8) = G_TRUNC %7(s32)
489 successors: %bb.3(0x80000000)
493 %9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
494 %10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
495 %11(s32) = G_ZEXT %9(s8)
496 %12(s32) = G_ZEXT %10(s8)
497 %13(s32) = G_ADD %11, %12
499 RET_ReallyLR implicit $w0
503 name: legalize_phi_diff_bb
505 exposesReturnsTwice: false
507 regBankSelected: false
509 tracksRegLiveness: true
511 - { id: 0, class: _, preferred-register: '' }
512 - { id: 1, class: _, preferred-register: '' }
513 - { id: 2, class: _, preferred-register: '' }
514 - { id: 3, class: _, preferred-register: '' }
515 - { id: 4, class: _, preferred-register: '' }
516 - { id: 5, class: _, preferred-register: '' }
517 - { id: 6, class: _, preferred-register: '' }
518 - { id: 7, class: _, preferred-register: '' }
519 - { id: 8, class: _, preferred-register: '' }
520 - { id: 9, class: _, preferred-register: '' }
521 - { id: 10, class: _, preferred-register: '' }
522 - { id: 11, class: _, preferred-register: '' }
523 - { id: 12, class: _, preferred-register: '' }
524 - { id: 13, class: _, preferred-register: '' }
525 - { id: 14, class: _, preferred-register: '' }
526 - { id: 15, class: _, preferred-register: '' }
529 ; CHECK-LABEL: name: legalize_phi_diff_bb
531 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
532 ; CHECK: liveins: $w0, $w1
533 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
534 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
535 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
536 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
537 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
538 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
539 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
540 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
541 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
542 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
543 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
544 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
547 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
548 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.0, %21(s16), %bb.1
549 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
550 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
551 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
552 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
553 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
554 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
555 ; CHECK: [[COPY2:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
556 ; CHECK: [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 43
557 ; CHECK: G_BRCOND [[TRUNC3]](s1), %bb.2
560 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY2]](s16), %bb.1, [[TRUNC1]](s16), %bb.0
561 ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
562 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
563 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
564 ; CHECK: $w0 = COPY [[AND1]](s32)
565 ; CHECK: RET_ReallyLR implicit $w0
567 successors: %bb.1(0x40000000), %bb.3(0x40000000)
569 ; Make sure that we correctly legalize PHIs sharing common defs
576 %2(s32) = G_CONSTANT i32 0
577 %4(s32) = G_CONSTANT i32 3
578 %9(s32) = G_CONSTANT i32 1
579 %11(s32) = G_CONSTANT i32 44
580 %15(s8) = G_CONSTANT i8 43
581 %3(s1) = G_ICMP intpred(ugt), %0(s32), %2
582 %5(s32) = G_ADD %0, %4
583 %6(s8) = G_TRUNC %5(s32)
584 G_BRCOND %3(s1), %bb.1
588 successors: %bb.3(0x40000000), %bb.1(0x40000000)
590 %7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
591 %8(s32) = G_ZEXT %7(s8)
592 %10(s32) = G_ADD %8, %9
593 %12(s1) = G_ICMP intpred(ugt), %10(s32), %11
594 G_BRCOND %12(s1), %bb.3
598 %13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
599 %14(s32) = G_ZEXT %13(s8)
601 RET_ReallyLR implicit $w0
605 name: legalize_phi_check_insertpt
607 exposesReturnsTwice: false
609 regBankSelected: false
611 tracksRegLiveness: true
613 ; Check that the G_MERGE here gets inserted after all the PHIs.
614 ; CHECK-LABEL: name: legalize_phi_check_insertpt
616 ; CHECK: successors: %bb.1(0x80000000)
617 ; CHECK: liveins: $x0, $x1
618 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
619 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
620 ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
621 ; CHECK: [[DEF1:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
624 ; CHECK: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
625 ; CHECK: [[PHI1:%[0-9]+]]:_(s64) = G_PHI [[DEF1]](s64), %bb.0
626 ; CHECK: [[PHI2:%[0-9]+]]:_(s64) = G_PHI [[COPY]](s64), %bb.0
627 ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[PHI]](s64), [[PHI1]](s64)
628 ; CHECK: G_STORE [[MV]](s128), [[COPY1]](p0) :: (store 16)
629 ; CHECK: G_STORE [[PHI2]](s64), [[COPY1]](p0) :: (store 8)
630 ; CHECK: RET_ReallyLR
632 successors: %bb.1(0x40000000)
637 %2:_(s128) = G_IMPLICIT_DEF
641 %3:_(s128) = G_PHI %2(s128), %bb.0
642 %4:_(s64) = G_PHI %0(s64), %bb.0
643 G_STORE %3(s128), %1(p0) :: (store 16)
644 G_STORE %4(s64), %1(p0) :: (store 8)