llvm-for-llvmta/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir

627 lines
21 KiB
Plaintext
Raw Permalink Normal View History

2022-04-25 10:02:23 +02:00
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -mtriple=aarch64-unknown-unknown -verify-machineinstrs -global-isel-abort=1 -run-pass=legalizer %s -o - | FileCheck %s
---
name: legalize_phi
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
- { id: 6, class: _, preferred-register: '' }
- { id: 7, class: _, preferred-register: '' }
- { id: 8, class: _, preferred-register: '' }
- { id: 9, class: _, preferred-register: '' }
- { id: 10, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: liveins: $w0
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: G_BR %bb.2
; CHECK: bb.1:
; CHECK: successors: %bb.3(0x80000000)
; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
; CHECK: G_BR %bb.3
; CHECK: bb.2:
; CHECK: successors: %bb.3(0x80000000)
; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
; CHECK: bb.3:
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
; CHECK: $w0 = COPY [[AND]](s32)
; CHECK: RET_ReallyLR implicit $w0
bb.0:
; Test that we insert legalization artifacts(Truncs here) into the correct BBs
; while legalizing the G_PHI to s16.
successors: %bb.1(0x40000000), %bb.2(0x40000000)
liveins: $w0
%0(s32) = COPY $w0
%1(s32) = G_CONSTANT i32 0
%3(s32) = G_CONSTANT i32 1
%6(s32) = G_CONSTANT i32 2
%2(s1) = G_ICMP intpred(ugt), %0(s32), %1
G_BRCOND %2(s1), %bb.1
G_BR %bb.2
bb.1:
successors: %bb.3(0x80000000)
%4(s32) = G_ADD %0, %3
%5(s1) = G_TRUNC %4(s32)
G_BR %bb.3
bb.2:
successors: %bb.3(0x80000000)
%7(s32) = G_ADD %0, %6
%8(s1) = G_TRUNC %7(s32)
bb.3:
%9(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
%11:_(s1) = G_PHI %5(s1), %bb.1, %8(s1), %bb.2
%10(s32) = G_ZEXT %9(s1)
$w0 = COPY %10(s32)
RET_ReallyLR implicit $w0
...
---
name: legalize_phi_ptr
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi_ptr
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: liveins: $w2, $x0, $x1
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $w2
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[COPY2]](s32)
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: G_BR %bb.2
; CHECK: bb.1:
; CHECK: successors: %bb.2(0x80000000)
; CHECK: bb.2:
; CHECK: [[PHI:%[0-9]+]]:_(p0) = G_PHI [[COPY]](p0), %bb.0, [[COPY1]](p0), %bb.1
; CHECK: $x0 = COPY [[PHI]](p0)
; CHECK: RET_ReallyLR implicit $x0
bb.1:
successors: %bb.2, %bb.3
liveins: $w2, $x0, $x1
%0(p0) = COPY $x0
%1(p0) = COPY $x1
%4(s32) = COPY $w2
%2(s1) = G_TRUNC %4(s32)
G_BRCOND %2(s1), %bb.2
G_BR %bb.3
bb.2:
successors: %bb.3
bb.3:
%3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2
$x0 = COPY %3(p0)
RET_ReallyLR implicit $x0
...
---
name: legalize_phi_empty
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
- { id: 6, class: _, preferred-register: '' }
- { id: 7, class: _, preferred-register: '' }
- { id: 8, class: _, preferred-register: '' }
- { id: 9, class: _, preferred-register: '' }
- { id: 10, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi_empty
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: liveins: $w0
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: G_BR %bb.2
; CHECK: bb.1:
; CHECK: successors: %bb.3(0x80000000)
; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
; CHECK: G_BR %bb.3
; CHECK: bb.2:
; CHECK: successors: %bb.3(0x80000000)
; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
; CHECK: bb.3:
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC2]](s16), %bb.2
; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
; CHECK: $w0 = COPY [[AND]](s32)
; CHECK: RET_ReallyLR implicit $w0
bb.0:
successors: %bb.1(0x40000000), %bb.2(0x40000000)
liveins: $w0
; Test that we properly legalize a phi with a predecessor that's empty
%0(s32) = COPY $w0
%1(s32) = G_CONSTANT i32 0
%3(s32) = G_CONSTANT i32 3
%6(s32) = G_CONSTANT i32 1
%2(s1) = G_ICMP intpred(ugt), %0(s32), %1
%4(s32) = G_ADD %0, %3
%5(s1) = G_TRUNC %4(s32)
G_BRCOND %2(s1), %bb.1
G_BR %bb.2
bb.1:
successors: %bb.3(0x80000000)
%7(s32) = G_ADD %0, %6
%8(s1) = G_TRUNC %7(s32)
G_BR %bb.3
bb.2:
successors: %bb.3(0x80000000)
bb.3:
%9(s1) = G_PHI %8(s1), %bb.1, %5(s1), %bb.2
%10(s32) = G_ZEXT %9(s1)
$w0 = COPY %10(s32)
RET_ReallyLR implicit $w0
...
---
name: legalize_phi_loop
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
- { id: 6, class: _, preferred-register: '' }
- { id: 7, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi_loop
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x80000000)
; CHECK: liveins: $w0
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
; CHECK: bb.1:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %13(s16), %bb.1
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[C1]]
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: bb.2:
; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C3]]
; CHECK: $w0 = COPY [[AND1]](s32)
; CHECK: RET_ReallyLR implicit $w0
bb.0:
successors: %bb.1(0x80000000)
liveins: $w0
; Test that we properly legalize a phi that uses a value from the same BB
%0(s32) = COPY $w0
%2(s8) = G_CONSTANT i8 1
%7(s8) = G_CONSTANT i8 0
bb.1:
successors: %bb.1(0x40000000), %bb.3(0x40000000)
%1(s8) = G_PHI %7(s8), %bb.0, %3(s8), %bb.1
%3(s8) = G_ADD %1, %2
%4(s32) = G_ZEXT %3(s8)
%5(s1) = G_ICMP intpred(ugt), %4(s32), %0
G_BRCOND %5(s1), %bb.1
bb.3:
%6(s32) = G_ZEXT %3(s8)
$w0 = COPY %6(s32)
RET_ReallyLR implicit $w0
...
---
name: legalize_phi_cycle
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi_cycle
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x80000000)
; CHECK: liveins: $w0
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
; CHECK: bb.1:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[C]](s16), %bb.0, %7(s16), %bb.1
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C1]]
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
; CHECK: [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: bb.2:
; CHECK: $w0 = COPY [[AND]](s32)
; CHECK: RET_ReallyLR implicit $w0
bb.0:
successors: %bb.1(0x80000000)
liveins: $w0
; Test that we properly legalize a phi that uses itself
%0(s32) = COPY $w0
%4(s8) = G_CONSTANT i8 0
bb.1:
successors: %bb.1(0x40000000), %bb.3(0x40000000)
%1(s8) = G_PHI %4(s8), %bb.0, %1(s8), %bb.1
%2(s32) = G_ZEXT %1(s8)
%3(s1) = G_ICMP intpred(ugt), %2(s32), %0
G_BRCOND %3(s1), %bb.1
bb.3:
$w0 = COPY %2(s32)
RET_ReallyLR implicit $w0
...
---
name: legalize_phi_same_bb
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
- { id: 6, class: _, preferred-register: '' }
- { id: 7, class: _, preferred-register: '' }
- { id: 8, class: _, preferred-register: '' }
- { id: 9, class: _, preferred-register: '' }
- { id: 10, class: _, preferred-register: '' }
- { id: 11, class: _, preferred-register: '' }
- { id: 12, class: _, preferred-register: '' }
- { id: 13, class: _, preferred-register: '' }
- { id: 14, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi_same_bb
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: liveins: $w0
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: G_BR %bb.2
; CHECK: bb.1:
; CHECK: successors: %bb.3(0x80000000)
; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C2]]
; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD1]](s32)
; CHECK: G_BR %bb.3
; CHECK: bb.2:
; CHECK: successors: %bb.3(0x80000000)
; CHECK: [[C3:%[0-9]+]]:_(s16) = G_CONSTANT i16 42
; CHECK: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
; CHECK: bb.3:
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC3]](s16), %bb.2
; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[C3]](s16), %bb.2
; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C4]]
; CHECK: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[AND1]]
; CHECK: $w0 = COPY [[ADD2]](s32)
; CHECK: RET_ReallyLR implicit $w0
bb.0:
successors: %bb.1(0x40000000), %bb.2(0x40000000)
liveins: $w0
; Make sure that we correctly insert the new legalized G_PHI at the
; correct location (ie make sure G_PHIs are the first insts in the BB).
%0(s32) = COPY $w0
%1(s32) = G_CONSTANT i32 0
%3(s32) = G_CONSTANT i32 3
%6(s32) = G_CONSTANT i32 1
%14(s8) = G_CONSTANT i8 42
%2(s1) = G_ICMP intpred(ugt), %0(s32), %1
%4(s32) = G_ADD %0, %3
%5(s8) = G_TRUNC %4(s32)
G_BRCOND %2(s1), %bb.1
G_BR %bb.2
bb.1:
successors: %bb.3(0x80000000)
%7(s32) = G_ADD %0, %6
%8(s8) = G_TRUNC %7(s32)
G_BR %bb.3
bb.2:
successors: %bb.3(0x80000000)
bb.3:
%9(s8) = G_PHI %8(s8), %bb.1, %5(s8), %bb.2
%10(s8) = G_PHI %8(s8), %bb.1, %14(s8), %bb.2
%11(s32) = G_ZEXT %9(s8)
%12(s32) = G_ZEXT %10(s8)
%13(s32) = G_ADD %11, %12
$w0 = COPY %13(s32)
RET_ReallyLR implicit $w0
...
---
name: legalize_phi_diff_bb
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
registers:
- { id: 0, class: _, preferred-register: '' }
- { id: 1, class: _, preferred-register: '' }
- { id: 2, class: _, preferred-register: '' }
- { id: 3, class: _, preferred-register: '' }
- { id: 4, class: _, preferred-register: '' }
- { id: 5, class: _, preferred-register: '' }
- { id: 6, class: _, preferred-register: '' }
- { id: 7, class: _, preferred-register: '' }
- { id: 8, class: _, preferred-register: '' }
- { id: 9, class: _, preferred-register: '' }
- { id: 10, class: _, preferred-register: '' }
- { id: 11, class: _, preferred-register: '' }
- { id: 12, class: _, preferred-register: '' }
- { id: 13, class: _, preferred-register: '' }
- { id: 14, class: _, preferred-register: '' }
- { id: 15, class: _, preferred-register: '' }
liveins:
body: |
; CHECK-LABEL: name: legalize_phi_diff_bb
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
; CHECK: liveins: $w0, $w1
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 44
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[COPY]](s32), [[C]]
; CHECK: [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY]], [[C1]]
; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
; CHECK: G_BRCOND [[TRUNC]](s1), %bb.1
; CHECK: G_BR %bb.2
; CHECK: bb.1:
; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.0, %21(s16), %bb.1
; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C4]]
; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
; CHECK: [[TRUNC3:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
; CHECK: [[COPY2:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
; CHECK: [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 43
; CHECK: G_BRCOND [[TRUNC3]](s1), %bb.2
; CHECK: G_BR %bb.1
; CHECK: bb.2:
; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY2]](s16), %bb.1, [[TRUNC1]](s16), %bb.0
; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C6]]
; CHECK: $w0 = COPY [[AND1]](s32)
; CHECK: RET_ReallyLR implicit $w0
bb.0:
successors: %bb.1(0x40000000), %bb.3(0x40000000)
liveins: $w0, $w1
; Make sure that we correctly legalize PHIs sharing common defs
; in different BBs.
%0(s32) = COPY $w0
%1(s32) = COPY $w1
%2(s32) = G_CONSTANT i32 0
%4(s32) = G_CONSTANT i32 3
%9(s32) = G_CONSTANT i32 1
%11(s32) = G_CONSTANT i32 44
%15(s8) = G_CONSTANT i8 43
%3(s1) = G_ICMP intpred(ugt), %0(s32), %2
%5(s32) = G_ADD %0, %4
%6(s8) = G_TRUNC %5(s32)
G_BRCOND %3(s1), %bb.1
G_BR %bb.3
bb.1:
successors: %bb.3(0x40000000), %bb.1(0x40000000)
%7(s8) = G_PHI %6(s8), %bb.0, %15(s8), %bb.1
%8(s32) = G_ZEXT %7(s8)
%10(s32) = G_ADD %8, %9
%12(s1) = G_ICMP intpred(ugt), %10(s32), %11
G_BRCOND %12(s1), %bb.3
G_BR %bb.1
bb.3:
%13(s8) = G_PHI %7(s8), %bb.1, %6(s8), %bb.0
%14(s32) = G_ZEXT %13(s8)
$w0 = COPY %14(s32)
RET_ReallyLR implicit $w0
...
---
name: legalize_phi_check_insertpt
alignment: 4
exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
tracksRegLiveness: true
body: |
; CHECK-LABEL: name: legalize_phi_check_insertpt
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x80000000)
; CHECK: liveins: $x0, $x1
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
; CHECK: G_BR %bb.1
; CHECK: bb.1:
; CHECK: [[PHI:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
; CHECK: [[PHI1:%[0-9]+]]:_(s64) = G_PHI [[DEF]](s64), %bb.0
; CHECK: [[PHI2:%[0-9]+]]:_(s64) = G_PHI [[COPY]](s64), %bb.0
; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[PHI]](s64), [[PHI1]](s64)
; CHECK: G_STORE [[MV]](s128), [[COPY1]](p0) :: (store 16)
; CHECK: G_STORE [[PHI2]](s64), [[COPY1]](p0) :: (store 8)
; CHECK: RET_ReallyLR
; Check that the G_MERGE here gets inserted after all the PHIs.
bb.0:
successors: %bb.1(0x40000000)
liveins: $x0, $x1
%0:_(s64) = COPY $x0
%1:_(p0) = COPY $x1
%2:_(s128) = G_IMPLICIT_DEF
G_BR %bb.1
bb.1:
%3:_(s128) = G_PHI %2(s128), %bb.0
%4:_(s64) = G_PHI %0(s64), %bb.0
G_STORE %3(s128), %1(p0) :: (store 16)
G_STORE %4(s64), %1(p0) :: (store 8)
RET_ReallyLR
...
---
name: legalize_phi_vector
tracksRegLiveness: true
body: |
; CHECK-LABEL: name: legalize_phi_vector
; CHECK: bb.0:
; CHECK: successors: %bb.1(0x80000000)
; CHECK: liveins: $q0, $x1
; CHECK: [[COPY:%[0-9]+]]:_(<16 x s8>) = COPY $q0
; CHECK: G_BR %bb.1
; CHECK: bb.1:
; CHECK: [[PHI:%[0-9]+]]:_(<16 x s8>) = G_PHI [[COPY]](<16 x s8>), %bb.0
; CHECK: $q0 = COPY [[PHI]](<16 x s8>)
; CHECK: RET_ReallyLR
bb.0:
successors: %bb.1
liveins: $q0, $x1
%0:_(<16 x s8>) = COPY $q0
G_BR %bb.1
bb.1:
%3:_(<16 x s8>) = G_PHI %0(<16 x s8>), %bb.0
$q0 = COPY %3(<16 x s8>)
RET_ReallyLR
...