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) {
47 exposesReturnsTwice: false
49 regBankSelected: false
51 tracksRegLiveness: true
53 - { id: 0, class: _, preferred-register: '' }
54 - { id: 1, class: _, preferred-register: '' }
55 - { id: 2, class: _, preferred-register: '' }
56 - { id: 3, class: _, preferred-register: '' }
57 - { id: 4, class: _, preferred-register: '' }
58 - { id: 5, class: _, preferred-register: '' }
59 - { id: 6, class: _, preferred-register: '' }
60 - { id: 7, class: _, preferred-register: '' }
61 - { id: 8, class: _, preferred-register: '' }
62 - { id: 9, class: _, preferred-register: '' }
63 - { id: 10, class: _, preferred-register: '' }
66 ; CHECK-LABEL: name: legalize_phi
68 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
70 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
71 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
72 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
73 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
74 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
75 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
76 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
79 ; CHECK: successors: %bb.3(0x80000000)
80 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
81 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
84 ; CHECK: successors: %bb.3(0x80000000)
85 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
86 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
88 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
89 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
90 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
91 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
92 ; CHECK: $w0 = COPY [[AND]](s32)
93 ; CHECK: RET_ReallyLR implicit $w0
95 ; Test that we insert legalization artifacts(Truncs here) into the correct BBs
96 ; while legalizing the G_PHI to s16.
99 successors: %bb.1(0x40000000), %bb.2(0x40000000)
103 %1(s32) = G_CONSTANT i32 0
104 %3(s32) = G_CONSTANT i32 1
105 %6(s32) = G_CONSTANT i32 2
106 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
107 G_BRCOND %2(s1), %bb.1
111 successors: %bb.3(0x80000000)
113 %4(s32) = G_ADD %0, %3
114 %5(s1) = G_TRUNC %4(s32)
118 successors: %bb.3(0x80000000)
120 %7(s32) = G_ADD %0, %6
121 %8(s1) = G_TRUNC %7(s32)
124 %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
125 %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
126 %10(s32) = G_ZEXT %9(s1)
128 RET_ReallyLR implicit $w0
132 name: legalize_phi_ptr
134 exposesReturnsTwice: false
136 regBankSelected: false
138 tracksRegLiveness: true
140 - { id: 0, class: _, preferred-register: '' }
141 - { id: 1, class: _, preferred-register: '' }
142 - { id: 2, class: _, preferred-register: '' }
143 - { id: 3, class: _, preferred-register: '' }
144 - { id: 4, class: _, preferred-register: '' }
145 - { id: 5, class: _, preferred-register: '' }
148 ; CHECK-LABEL: name: legalize_phi_ptr
150 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
151 ; CHECK: liveins: $w2, $x0, $x1
152 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
153 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
154 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
155 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32)
156 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
159 ; CHECK: successors: %bb.2(0x80000000)
161 ; CHECK: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
162 ; CHECK: $x0 = COPY [[PHI]](p0)
163 ; CHECK: RET_ReallyLR implicit $x0
166 successors: %bb.2, %bb.3
167 liveins: $w2, $x0, $x1
172 %2(s1) = G_TRUNC %4(s32)
173 G_BRCOND %2(s1), %bb.2
180 %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
182 RET_ReallyLR implicit $x0
186 name: legalize_phi_empty
188 exposesReturnsTwice: false
190 regBankSelected: false
192 tracksRegLiveness: true
194 - { id: 0, class: _, preferred-register: '' }
195 - { id: 1, class: _, preferred-register: '' }
196 - { id: 2, class: _, preferred-register: '' }
197 - { id: 3, class: _, preferred-register: '' }
198 - { id: 4, class: _, preferred-register: '' }
199 - { id: 5, class: _, preferred-register: '' }
200 - { id: 6, class: _, preferred-register: '' }
201 - { id: 7, class: _, preferred-register: '' }
202 - { id: 8, class: _, preferred-register: '' }
203 - { id: 9, class: _, preferred-register: '' }
204 - { id: 10, class: _, preferred-register: '' }
207 ; CHECK-LABEL: name: legalize_phi_empty
209 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
210 ; CHECK: liveins: $w0
211 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
212 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
213 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
214 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
215 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
216 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
217 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
218 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
221 ; CHECK: successors: %bb.3(0x80000000)
222 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
223 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
226 ; CHECK: successors: %bb.3(0x80000000)
227 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
229 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
230 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
231 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
232 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
233 ; CHECK: $w0 = COPY [[AND]](s32)
234 ; CHECK: RET_ReallyLR implicit $w0
236 successors: %bb.1(0x40000000), %bb.2(0x40000000)
238 ; Test that we properly legalize a phi with a predecessor that's empty
244 %1(s32) = G_CONSTANT i32 0
245 %3(s32) = G_CONSTANT i32 3
246 %6(s32) = G_CONSTANT i32 1
247 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
248 %4(s32) = G_ADD %0, %3
249 %5(s1) = G_TRUNC %4(s32)
250 G_BRCOND %2(s1), %bb.1
254 successors: %bb.3(0x80000000)
256 %7(s32) = G_ADD %0, %6
257 %8(s1) = G_TRUNC %7(s32)
261 successors: %bb.3(0x80000000)
265 %9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
266 %10(s32) = G_ZEXT %9(s1)
268 RET_ReallyLR implicit $w0
272 name: legalize_phi_loop
274 exposesReturnsTwice: false
276 regBankSelected: false
278 tracksRegLiveness: true
280 - { id: 0, class: _, preferred-register: '' }
281 - { id: 1, class: _, preferred-register: '' }
282 - { id: 2, class: _, preferred-register: '' }
283 - { id: 3, class: _, preferred-register: '' }
284 - { id: 4, class: _, preferred-register: '' }
285 - { id: 5, class: _, preferred-register: '' }
286 - { id: 6, class: _, preferred-register: '' }
287 - { id: 7, class: _, preferred-register: '' }
290 ; CHECK-LABEL: name: legalize_phi_loop
292 ; CHECK: successors: %bb.1(0x80000000)
293 ; CHECK: liveins: $w0
294 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
295 ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
297 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
298 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %13(s16), %bb.1
299 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
300 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
301 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[C1]]
302 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
303 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
304 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
305 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
306 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
307 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
308 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
310 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
311 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
312 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C3]]
313 ; CHECK: $w0 = COPY [[AND1]](s32)
314 ; CHECK: RET_ReallyLR implicit $w0
316 successors: %bb.1(0x80000000)
318 ; Test that we properly legalize a phi that uses a value from the same BB
321 %2(s8) = G_CONSTANT i8 1
322 %7(s8) = G_CONSTANT i8 0
325 successors: %bb.1(0x40000000), %bb.3(0x40000000)
327 %1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
328 %3(s8) = G_ADD %1, %2
329 %4(s32) = G_ZEXT %3(s8)
330 %5(s1) = G_ICMP intpred(ugt), %4(s32), %0
331 G_BRCOND %5(s1), %bb.1
334 %6(s32) = G_ZEXT %3(s8)
336 RET_ReallyLR implicit $w0
340 name: legalize_phi_cycle
342 exposesReturnsTwice: false
344 regBankSelected: false
346 tracksRegLiveness: true
348 - { id: 0, class: _, preferred-register: '' }
349 - { id: 1, class: _, preferred-register: '' }
350 - { id: 2, class: _, preferred-register: '' }
351 - { id: 3, class: _, preferred-register: '' }
352 - { id: 4, class: _, preferred-register: '' }
355 ; CHECK-LABEL: name: legalize_phi_cycle
357 ; CHECK: successors: %bb.1(0x80000000)
358 ; CHECK: liveins: $w0
359 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
360 ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
362 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
363 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %7(s16), %bb.1
364 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
365 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
366 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
367 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
368 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
369 ; CHECK: [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
370 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
372 ; CHECK: $w0 = COPY [[AND]](s32)
373 ; CHECK: RET_ReallyLR implicit $w0
375 successors: %bb.1(0x80000000)
377 ; Test that we properly legalize a phi that uses itself
381 %4(s8) = G_CONSTANT i8 0
384 successors: %bb.1(0x40000000), %bb.3(0x40000000)
386 %1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
387 %2(s32) = G_ZEXT %1(s8)
388 %3(s1) = G_ICMP intpred(ugt), %2(s32), %0
389 G_BRCOND %3(s1), %bb.1
393 RET_ReallyLR implicit $w0
397 name: legalize_phi_same_bb
399 exposesReturnsTwice: false
401 regBankSelected: false
403 tracksRegLiveness: true
405 - { id: 0, class: _, preferred-register: '' }
406 - { id: 1, class: _, preferred-register: '' }
407 - { id: 2, class: _, preferred-register: '' }
408 - { id: 3, class: _, preferred-register: '' }
409 - { id: 4, class: _, preferred-register: '' }
410 - { id: 5, class: _, preferred-register: '' }
411 - { id: 6, class: _, preferred-register: '' }
412 - { id: 7, class: _, preferred-register: '' }
413 - { id: 8, class: _, preferred-register: '' }
414 - { id: 9, class: _, preferred-register: '' }
415 - { id: 10, class: _, preferred-register: '' }
416 - { id: 11, class: _, preferred-register: '' }
417 - { id: 12, class: _, preferred-register: '' }
418 - { id: 13, class: _, preferred-register: '' }
419 - { id: 14, class: _, preferred-register: '' }
422 ; CHECK-LABEL: name: legalize_phi_same_bb
424 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
425 ; CHECK: liveins: $w0
426 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
427 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
428 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
429 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
430 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
431 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
432 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
433 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
436 ; CHECK: successors: %bb.3(0x80000000)
437 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
438 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
439 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
442 ; CHECK: successors: %bb.3(0x80000000)
443 ; CHECK: [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 42
444 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
446 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC3]](s16), %bb.2
447 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[C3]](s16), %bb.2
448 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
449 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
450 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
451 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
452 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C4]]
453 ; CHECK: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
454 ; CHECK: $w0 = COPY [[ADD2]](s32)
455 ; CHECK: RET_ReallyLR implicit $w0
457 successors: %bb.1(0x40000000), %bb.2(0x40000000)
459 ; Make sure that we correctly insert the new legalized G_PHI at the
460 ; correct location (ie make sure G_PHIs are the first insts in the BB).
466 %1(s32) = G_CONSTANT i32 0
467 %3(s32) = G_CONSTANT i32 3
468 %6(s32) = G_CONSTANT i32 1
469 %14(s8) = G_CONSTANT i8 42
470 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
471 %4(s32) = G_ADD %0, %3
472 %5(s8) = G_TRUNC %4(s32)
473 G_BRCOND %2(s1), %bb.1
477 successors: %bb.3(0x80000000)
479 %7(s32) = G_ADD %0, %6
480 %8(s8) = G_TRUNC %7(s32)
484 successors: %bb.3(0x80000000)
488 %9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
489 %10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
490 %11(s32) = G_ZEXT %9(s8)
491 %12(s32) = G_ZEXT %10(s8)
492 %13(s32) = G_ADD %11, %12
494 RET_ReallyLR implicit $w0
498 name: legalize_phi_diff_bb
500 exposesReturnsTwice: false
502 regBankSelected: false
504 tracksRegLiveness: true
506 - { id: 0, class: _, preferred-register: '' }
507 - { id: 1, class: _, preferred-register: '' }
508 - { id: 2, class: _, preferred-register: '' }
509 - { id: 3, class: _, preferred-register: '' }
510 - { id: 4, class: _, preferred-register: '' }
511 - { id: 5, class: _, preferred-register: '' }
512 - { id: 6, class: _, preferred-register: '' }
513 - { id: 7, class: _, preferred-register: '' }
514 - { id: 8, class: _, preferred-register: '' }
515 - { id: 9, class: _, preferred-register: '' }
516 - { id: 10, class: _, preferred-register: '' }
517 - { id: 11, class: _, preferred-register: '' }
518 - { id: 12, class: _, preferred-register: '' }
519 - { id: 13, class: _, preferred-register: '' }
520 - { id: 14, class: _, preferred-register: '' }
521 - { id: 15, class: _, preferred-register: '' }
524 ; CHECK-LABEL: name: legalize_phi_diff_bb
526 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
527 ; CHECK: liveins: $w0, $w1
528 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
529 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
530 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
531 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
532 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
533 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
534 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
535 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
536 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
537 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
538 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
539 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
542 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
543 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.0, %21(s16), %bb.1
544 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
545 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
546 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
547 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
548 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
549 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
550 ; CHECK: [[COPY2:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
551 ; CHECK: [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 43
552 ; CHECK: G_BRCOND [[TRUNC3]](s1), %bb.2
555 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY2]](s16), %bb.1, [[TRUNC1]](s16), %bb.0
556 ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
557 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
558 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
559 ; CHECK: $w0 = COPY [[AND1]](s32)
560 ; CHECK: RET_ReallyLR implicit $w0
562 successors: %bb.1(0x40000000), %bb.3(0x40000000)
564 ; Make sure that we correctly legalize PHIs sharing common defs
571 %2(s32) = G_CONSTANT i32 0
572 %4(s32) = G_CONSTANT i32 3
573 %9(s32) = G_CONSTANT i32 1
574 %11(s32) = G_CONSTANT i32 44
575 %15(s8) = G_CONSTANT i8 43
576 %3(s1) = G_ICMP intpred(ugt), %0(s32), %2
577 %5(s32) = G_ADD %0, %4
578 %6(s8) = G_TRUNC %5(s32)
579 G_BRCOND %3(s1), %bb.1
583 successors: %bb.3(0x40000000), %bb.1(0x40000000)
585 %7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
586 %8(s32) = G_ZEXT %7(s8)
587 %10(s32) = G_ADD %8, %9
588 %12(s1) = G_ICMP intpred(ugt), %10(s32), %11
589 G_BRCOND %12(s1), %bb.3
593 %13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
594 %14(s32) = G_ZEXT %13(s8)
596 RET_ReallyLR implicit $w0