forked from OSchip/llvm-project
606 lines
20 KiB
YAML
606 lines
20 KiB
YAML
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
|
|
# RUN: llc -mtriple=aarch64-unknown-unknown -global-isel -verify-machineinstrs -run-pass=legalizer %s -o - | FileCheck %s
|
|
--- |
|
|
; ModuleID = '/tmp/test.ll'
|
|
source_filename = "/tmp/test.ll"
|
|
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
|
target triple = "aarch64-unknown-unknown"
|
|
|
|
define i32 @legalize_phi(i32 %argc) {
|
|
entry:
|
|
ret i32 0
|
|
}
|
|
|
|
define i64* @legalize_phi_ptr(i64* %a, i64* %b, i1 %cond) {
|
|
entry:
|
|
ret i64* null
|
|
}
|
|
|
|
define i32 @legalize_phi_empty(i32 %argc) {
|
|
entry:
|
|
ret i32 0
|
|
}
|
|
|
|
define i32 @legalize_phi_loop(i32 %argc) {
|
|
entry:
|
|
ret i32 0
|
|
}
|
|
|
|
define i32 @legalize_phi_cycle(i32 %argc) {
|
|
entry:
|
|
ret i32 0
|
|
}
|
|
define i32 @legalize_phi_same_bb(i32 %argc) {
|
|
entry:
|
|
ret i32 0
|
|
}
|
|
|
|
define i32 @legalize_phi_diff_bb(i32 %argc, i32 %argc2) {
|
|
entry:
|
|
ret i32 0
|
|
}
|
|
|
|
...
|
|
---
|
|
name: legalize_phi
|
|
alignment: 2
|
|
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
|
|
%10(s32) = G_ZEXT %9(s1)
|
|
$w0 = COPY %10(s32)
|
|
RET_ReallyLR implicit $w0
|
|
|
|
...
|
|
---
|
|
name: legalize_phi_ptr
|
|
alignment: 2
|
|
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: 2
|
|
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: 2
|
|
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]+]]:_(s32) = G_CONSTANT i32 1
|
|
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
|
|
; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[C1]](s32)
|
|
; CHECK: bb.1:
|
|
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
|
|
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.0, %14(s16), %bb.1
|
|
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
|
|
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
|
|
; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ANYEXT]], [[COPY1]]
|
|
; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[ADD]](s32)
|
|
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
|
|
; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
|
|
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C2]]
|
|
; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[AND]](s32), [[COPY]]
|
|
; CHECK: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
|
|
; CHECK: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
|
|
; CHECK: G_BRCOND [[TRUNC2]](s1), %bb.1
|
|
; CHECK: bb.2:
|
|
; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
|
|
; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
|
|
; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[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: 2
|
|
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]+]]:_(s32) = G_CONSTANT i32 0
|
|
; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[C]](s32)
|
|
; CHECK: bb.1:
|
|
; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
|
|
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC]](s16), %bb.0, %8(s16), %bb.1
|
|
; CHECK: [[TRUNC1:%[0-9]+]]:_(s8) = G_TRUNC [[PHI]](s16)
|
|
; 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: [[TRUNC2:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP]](s32)
|
|
; CHECK: [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
|
|
; CHECK: G_BRCOND [[TRUNC2]](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: 2
|
|
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: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
|
|
; 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: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[C3]](s32)
|
|
; CHECK: [[TRUNC4:%[0-9]+]]:_(s16) = G_TRUNC [[ADD]](s32)
|
|
; CHECK: bb.3:
|
|
; CHECK: [[PHI:%[0-9]+]]:_(s16) = G_PHI [[TRUNC2]](s16), %bb.1, [[TRUNC4]](s16), %bb.2
|
|
; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[TRUNC1]](s16), %bb.1, [[TRUNC3]](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: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
|
|
; CHECK: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI1]](s16)
|
|
; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ANYEXT1]], [[C5]]
|
|
; CHECK: [[ADD2:%[0-9]+]]:_(s32) = G_ADD [[C]]1, [[C]]2
|
|
; CHECK: $w0 = COPY [[C]]3(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: 2
|
|
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: [[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: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 43
|
|
; 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, [[C]]2(s16), %bb.1
|
|
; CHECK: [[TRUNC3:%[0-9]+]]:_(s8) = G_TRUNC [[PHI]](s16)
|
|
; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
|
|
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
|
|
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C5]]
|
|
; CHECK: [[ADD1:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C2]]
|
|
; CHECK: [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ugt), [[ADD1]](s32), [[C3]]
|
|
; CHECK: [[TRUNC4:%[0-9]+]]:_(s1) = G_TRUNC [[ICMP1]](s32)
|
|
; CHECK: [[COPY1:%[0-9]+]]:_(s16) = COPY [[PHI]](s16)
|
|
; CHECK: [[TRUNC5:%[0-9]+]]:_(s16) = G_TRUNC [[C4]](s32)
|
|
; CHECK: G_BRCOND [[TRUNC4]](s1), %bb.2
|
|
; CHECK: G_BR %bb.1
|
|
; CHECK: bb.2:
|
|
; CHECK: [[PHI1:%[0-9]+]]:_(s16) = G_PHI [[COPY1]](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 [[C]]8, [[C]]7
|
|
; 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
|
|
|
|
...
|