1 # RUN: llc -O0 -mtriple=aarch64-unknown-unknown -verify-machineinstrs -run-pass=legalizer %s -o - | FileCheck %s
3 ; ModuleID = '/tmp/test.ll'
4 source_filename = "/tmp/test.ll"
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6 target triple = "aarch64-unknown-unknown"
8 define i32 @legalize_phi(i32 %argc) {
13 define i64* @legalize_phi_ptr(i64* %a, i64* %b, i1 %cond) {
18 define i32 @legalize_phi_empty(i32 %argc) {
23 define i32 @legalize_phi_loop(i32 %argc) {
28 define i32 @legalize_phi_cycle(i32 %argc) {
32 define i32 @legalize_phi_same_bb(i32 %argc) {
37 define i32 @legalize_phi_diff_bb(i32 %argc, i32 %argc2) {
46 exposesReturnsTwice: false
48 regBankSelected: false
50 tracksRegLiveness: true
52 - { id: 0, class: _, preferred-register: '' }
53 - { id: 1, class: _, preferred-register: '' }
54 - { id: 2, class: _, preferred-register: '' }
55 - { id: 3, class: _, preferred-register: '' }
56 - { id: 4, class: _, preferred-register: '' }
57 - { id: 5, class: _, preferred-register: '' }
58 - { id: 6, class: _, preferred-register: '' }
59 - { id: 7, class: _, preferred-register: '' }
60 - { id: 8, class: _, preferred-register: '' }
61 - { id: 9, class: _, preferred-register: '' }
62 - { id: 10, class: _, preferred-register: '' }
65 ; CHECK-LABEL: name: legalize_phi
67 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
69 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
70 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
71 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
72 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
73 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
74 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
75 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
78 ; CHECK: successors: %bb.3(0x80000000)
79 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
80 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
83 ; CHECK: successors: %bb.3(0x80000000)
84 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
85 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
87 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
88 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
89 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
90 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
91 ; CHECK: $w0 = COPY [[AND]](s32)
92 ; CHECK: RET_ReallyLR implicit $w0
94 ; Test that we insert legalization artifacts(Truncs here) into the correct BBs
95 ; while legalizing the G_PHI to s16.
98 successors: %bb.1(0x40000000), %bb.2(0x40000000)
102 %1(s32) = G_CONSTANT i32 0
103 %3(s32) = G_CONSTANT i32 1
104 %6(s32) = G_CONSTANT i32 2
105 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
106 G_BRCOND %2(s1), %bb.1
110 successors: %bb.3(0x80000000)
112 %4(s32) = G_ADD %0, %3
113 %5(s1) = G_TRUNC %4(s32)
117 successors: %bb.3(0x80000000)
119 %7(s32) = G_ADD %0, %6
120 %8(s1) = G_TRUNC %7(s32)
123 %9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
124 %11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
125 %10(s32) = G_ZEXT %9(s1)
127 RET_ReallyLR implicit $w0
131 name: legalize_phi_ptr
133 exposesReturnsTwice: false
135 regBankSelected: false
137 tracksRegLiveness: true
139 - { id: 0, class: _, preferred-register: '' }
140 - { id: 1, class: _, preferred-register: '' }
141 - { id: 2, class: _, preferred-register: '' }
142 - { id: 3, class: _, preferred-register: '' }
143 - { id: 4, class: _, preferred-register: '' }
144 - { id: 5, class: _, preferred-register: '' }
147 ; CHECK-LABEL: name: legalize_phi_ptr
149 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
150 ; CHECK: liveins: $w2, $x0, $x1
151 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
152 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
153 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
154 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32)
155 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
158 ; CHECK: successors: %bb.2(0x80000000)
160 ; CHECK: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
161 ; CHECK: $x0 = COPY [[PHI]](p0)
162 ; CHECK: RET_ReallyLR implicit $x0
165 successors: %bb.2, %bb.3
166 liveins: $w2, $x0, $x1
171 %2(s1) = G_TRUNC %4(s32)
172 G_BRCOND %2(s1), %bb.2
179 %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
181 RET_ReallyLR implicit $x0
185 name: legalize_phi_empty
187 exposesReturnsTwice: false
189 regBankSelected: false
191 tracksRegLiveness: true
193 - { id: 0, class: _, preferred-register: '' }
194 - { id: 1, class: _, preferred-register: '' }
195 - { id: 2, class: _, preferred-register: '' }
196 - { id: 3, class: _, preferred-register: '' }
197 - { id: 4, class: _, preferred-register: '' }
198 - { id: 5, class: _, preferred-register: '' }
199 - { id: 6, class: _, preferred-register: '' }
200 - { id: 7, class: _, preferred-register: '' }
201 - { id: 8, class: _, preferred-register: '' }
202 - { id: 9, class: _, preferred-register: '' }
203 - { id: 10, class: _, preferred-register: '' }
206 ; CHECK-LABEL: name: legalize_phi_empty
208 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
209 ; CHECK: liveins: $w0
210 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
211 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
212 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
213 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
214 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
215 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
216 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
217 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
220 ; CHECK: successors: %bb.3(0x80000000)
221 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
222 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
225 ; CHECK: successors: %bb.3(0x80000000)
226 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
228 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
229 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
230 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
231 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
232 ; CHECK: $w0 = COPY [[AND]](s32)
233 ; CHECK: RET_ReallyLR implicit $w0
235 successors: %bb.1(0x40000000), %bb.2(0x40000000)
237 ; Test that we properly legalize a phi with a predecessor that's empty
243 %1(s32) = G_CONSTANT i32 0
244 %3(s32) = G_CONSTANT i32 3
245 %6(s32) = G_CONSTANT i32 1
246 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
247 %4(s32) = G_ADD %0, %3
248 %5(s1) = G_TRUNC %4(s32)
249 G_BRCOND %2(s1), %bb.1
253 successors: %bb.3(0x80000000)
255 %7(s32) = G_ADD %0, %6
256 %8(s1) = G_TRUNC %7(s32)
260 successors: %bb.3(0x80000000)
264 %9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
265 %10(s32) = G_ZEXT %9(s1)
267 RET_ReallyLR implicit $w0
271 name: legalize_phi_loop
273 exposesReturnsTwice: false
275 regBankSelected: false
277 tracksRegLiveness: true
279 - { id: 0, class: _, preferred-register: '' }
280 - { id: 1, class: _, preferred-register: '' }
281 - { id: 2, class: _, preferred-register: '' }
282 - { id: 3, class: _, preferred-register: '' }
283 - { id: 4, class: _, preferred-register: '' }
284 - { id: 5, class: _, preferred-register: '' }
285 - { id: 6, class: _, preferred-register: '' }
286 - { id: 7, class: _, preferred-register: '' }
289 ; CHECK-LABEL: name: legalize_phi_loop
291 ; CHECK: successors: %bb.1(0x80000000)
292 ; CHECK: liveins: $w0
293 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
294 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
295 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
296 ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[C1]](s32)
298 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
299 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.0, [[TRUNC3:%[0-9]+]](s16), %bb.1
300 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
301 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
302 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[COPY1]]
303 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[ADD]](s32)
304 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
305 ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
306 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C2]]
307 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
308 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
309 ; CHECK: [[TRUNC3]]:_(s16) = G_TRUNC [[ADD]](s32)
310 ; CHECK: G_BRCOND [[TRUNC2]](s1), %bb.1
312 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
313 ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
314 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C3]]
315 ; CHECK: $w0 = COPY [[AND1]](s32)
316 ; CHECK: RET_ReallyLR implicit $w0
318 successors: %bb.1(0x80000000)
320 ; Test that we properly legalize a phi that uses a value from the same BB
323 %2(s8) = G_CONSTANT i8 1
324 %7(s8) = G_CONSTANT i8 0
327 successors: %bb.1(0x40000000), %bb.3(0x40000000)
329 %1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
330 %3(s8) = G_ADD %1, %2
331 %4(s32) = G_ZEXT %3(s8)
332 %5(s1) = G_ICMP intpred(ugt), %4(s32), %0
333 G_BRCOND %5(s1), %bb.1
336 %6(s32) = G_ZEXT %3(s8)
338 RET_ReallyLR implicit $w0
342 name: legalize_phi_cycle
344 exposesReturnsTwice: false
346 regBankSelected: false
348 tracksRegLiveness: true
350 - { id: 0, class: _, preferred-register: '' }
351 - { id: 1, class: _, preferred-register: '' }
352 - { id: 2, class: _, preferred-register: '' }
353 - { id: 3, class: _, preferred-register: '' }
354 - { id: 4, class: _, preferred-register: '' }
357 ; CHECK-LABEL: name: legalize_phi_cycle
359 ; CHECK: successors: %bb.1(0x80000000)
360 ; CHECK: liveins: $w0
361 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
362 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
363 ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[C]](s32)
365 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
366 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.0, [[COPY1:%[0-9]+]](s16), %bb.1
367 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[PHI]](s16)
368 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
369 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
370 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
371 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
372 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
373 ; CHECK: [[COPY1]]:_(s16) = COPY [[PHI]](s16)
374 ; CHECK: G_BRCOND [[TRUNC2]](s1), %bb.1
376 ; CHECK: $w0 = COPY [[AND]](s32)
377 ; CHECK: RET_ReallyLR implicit $w0
379 successors: %bb.1(0x80000000)
381 ; Test that we properly legalize a phi that uses itself
385 %4(s8) = G_CONSTANT i8 0
388 successors: %bb.1(0x40000000), %bb.3(0x40000000)
390 %1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
391 %2(s32) = G_ZEXT %1(s8)
392 %3(s1) = G_ICMP intpred(ugt), %2(s32), %0
393 G_BRCOND %3(s1), %bb.1
397 RET_ReallyLR implicit $w0
401 name: legalize_phi_same_bb
403 exposesReturnsTwice: false
405 regBankSelected: false
407 tracksRegLiveness: true
409 - { id: 0, class: _, preferred-register: '' }
410 - { id: 1, class: _, preferred-register: '' }
411 - { id: 2, class: _, preferred-register: '' }
412 - { id: 3, class: _, preferred-register: '' }
413 - { id: 4, class: _, preferred-register: '' }
414 - { id: 5, class: _, preferred-register: '' }
415 - { id: 6, class: _, preferred-register: '' }
416 - { id: 7, class: _, preferred-register: '' }
417 - { id: 8, class: _, preferred-register: '' }
418 - { id: 9, class: _, preferred-register: '' }
419 - { id: 10, class: _, preferred-register: '' }
420 - { id: 11, class: _, preferred-register: '' }
421 - { id: 12, class: _, preferred-register: '' }
422 - { id: 13, class: _, preferred-register: '' }
423 - { id: 14, class: _, preferred-register: '' }
426 ; CHECK-LABEL: name: legalize_phi_same_bb
428 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
429 ; CHECK: liveins: $w0
430 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
431 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
432 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
433 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
434 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
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: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[C3]](s32)
449 ; CHECK: [[TRUNC4:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
451 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC4]](s16), %bb.2
452 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC3]](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: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
457 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
458 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C5]]
459 ; CHECK: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
460 ; CHECK: $w0 = COPY [[ADD2]](s32)
461 ; CHECK: RET_ReallyLR implicit $w0
463 successors: %bb.1(0x40000000), %bb.2(0x40000000)
465 ; Make sure that we correctly insert the new legalized G_PHI at the
466 ; correct location (ie make sure G_PHIs are the first insts in the BB).
472 %1(s32) = G_CONSTANT i32 0
473 %3(s32) = G_CONSTANT i32 3
474 %6(s32) = G_CONSTANT i32 1
475 %14(s8) = G_CONSTANT i8 42
476 %2(s1) = G_ICMP intpred(ugt), %0(s32), %1
477 %4(s32) = G_ADD %0, %3
478 %5(s8) = G_TRUNC %4(s32)
479 G_BRCOND %2(s1), %bb.1
483 successors: %bb.3(0x80000000)
485 %7(s32) = G_ADD %0, %6
486 %8(s8) = G_TRUNC %7(s32)
490 successors: %bb.3(0x80000000)
494 %9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
495 %10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
496 %11(s32) = G_ZEXT %9(s8)
497 %12(s32) = G_ZEXT %10(s8)
498 %13(s32) = G_ADD %11, %12
500 RET_ReallyLR implicit $w0
504 name: legalize_phi_diff_bb
506 exposesReturnsTwice: false
508 regBankSelected: false
510 tracksRegLiveness: true
512 - { id: 0, class: _, preferred-register: '' }
513 - { id: 1, class: _, preferred-register: '' }
514 - { id: 2, class: _, preferred-register: '' }
515 - { id: 3, class: _, preferred-register: '' }
516 - { id: 4, class: _, preferred-register: '' }
517 - { id: 5, class: _, preferred-register: '' }
518 - { id: 6, class: _, preferred-register: '' }
519 - { id: 7, class: _, preferred-register: '' }
520 - { id: 8, class: _, preferred-register: '' }
521 - { id: 9, class: _, preferred-register: '' }
522 - { id: 10, class: _, preferred-register: '' }
523 - { id: 11, class: _, preferred-register: '' }
524 - { id: 12, class: _, preferred-register: '' }
525 - { id: 13, class: _, preferred-register: '' }
526 - { id: 14, class: _, preferred-register: '' }
527 - { id: 15, class: _, preferred-register: '' }
530 ; CHECK-LABEL: name: legalize_phi_diff_bb
532 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
533 ; CHECK: liveins: $w0, $w1
534 ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
535 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
536 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
537 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
538 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
539 ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
540 ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 43
541 ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
542 ; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
543 ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
544 ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
545 ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
546 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
549 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
550 ; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.0, [[TRUNC5:%[0-9]+]](s16), %bb.1
551 ; CHECK: [[TRUNC3:%[0-9]+]]:_(s8) = G_TRUNC [[PHI]](s16)
552 ; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
553 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
554 ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C5]]
555 ; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
556 ; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
557 ; CHECK: [[TRUNC4:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
558 ; CHECK: [[COPY2:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
559 ; CHECK: [[TRUNC5]]:_(s16) = G_TRUNC [[C4]](s32)
560 ; CHECK: G_BRCOND [[TRUNC4]](s1), %bb.2
563 ; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY2]](s16), %bb.1, [[TRUNC1]](s16), %bb.0
564 ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
565 ; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
566 ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
567 ; CHECK: $w0 = COPY [[AND1]](s32)
568 ; CHECK: RET_ReallyLR implicit $w0
570 successors: %bb.1(0x40000000), %bb.3(0x40000000)
572 ; Make sure that we correctly legalize PHIs sharing common defs
579 %2(s32) = G_CONSTANT i32 0
580 %4(s32) = G_CONSTANT i32 3
581 %9(s32) = G_CONSTANT i32 1
582 %11(s32) = G_CONSTANT i32 44
583 %15(s8) = G_CONSTANT i8 43
584 %3(s1) = G_ICMP intpred(ugt), %0(s32), %2
585 %5(s32) = G_ADD %0, %4
586 %6(s8) = G_TRUNC %5(s32)
587 G_BRCOND %3(s1), %bb.1
591 successors: %bb.3(0x40000000), %bb.1(0x40000000)
593 %7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
594 %8(s32) = G_ZEXT %7(s8)
595 %10(s32) = G_ADD %8, %9
596 %12(s1) = G_ICMP intpred(ugt), %10(s32), %11
597 G_BRCOND %12(s1), %bb.3
601 %13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
602 %14(s32) = G_ZEXT %13(s8)
604 RET_ReallyLR implicit $w0