1 # RUN: llc -mtriple amdgcn -run-pass livevars -run-pass phi-node-elimination -o - %s | FileCheck %s
3 ################################################################################
4 # This test used to hit an assert in PHIElimination:
5 # PHIElimination::LowerPHINode(llvm::MachineBasicBlock&, llvm::MachineBasicBlock::iterator): Assertion `KillInst->readsRegister(SrcReg) && "Cannot find kill instruction"'
9 tracksRegLiveness: true
12 S_CBRANCH_SCC0 %bb.2, implicit undef $scc
15 %1:sreg_32_xm0 = S_MOV_B32 255
19 %2:sreg_32_xm0 = S_MOV_B32 254
22 dead %3:sreg_32_xm0 = PHI undef %2, %bb.2, undef %1, %bb.1
23 %4:sreg_32_xm0 = PHI %2, %bb.2, %1, %bb.1
27 # CHECK-LABEL: name: foo
29 # CHECK-NEXT: dead %2:sreg_32_xm0 = IMPLICIT_DEF
30 # CHECK-NEXT: %3:sreg_32_xm0 = COPY killed %4
31 # CHECK-NEXT: S_NOP 0, implicit killed %3
34 ################################################################################
35 # Similar test as above, but with swapped order for the PHI nodes.
36 # With this PHI node order we did not hit the assert, but we used to get
39 # dead %3:sreg_32_xm0 = COPY killed %4
40 # %2:sreg_32_xm0 = COPY %4
41 # S_NOP 0, implicit killed %2
43 # which looks weird regarding killed flags for %4.
47 tracksRegLiveness: true
50 S_CBRANCH_SCC0 %bb.2, implicit undef $scc
53 %1:sreg_32_xm0 = S_MOV_B32 255
57 %2:sreg_32_xm0 = S_MOV_B32 254
60 %4:sreg_32_xm0 = PHI %2, %bb.2, %1, %bb.1
61 dead %3:sreg_32_xm0 = PHI undef %2, %bb.2, undef %1, %bb.1
65 # CHECK-LABEL: name: bar
67 # CHECK-NEXT: dead %3:sreg_32_xm0 = IMPLICIT_DEF
68 # CHECK-NEXT: %2:sreg_32_xm0 = COPY killed %4
69 # CHECK-NEXT: S_NOP 0, implicit killed %2
72 # The following test crashes in phi-elimination hooks.
77 tracksRegLiveness: true
80 S_CBRANCH_SCC0 %bb.2, implicit undef $scc
83 %1:sreg_32_xm0 = S_MOV_B32 255
87 %2:sreg_32_xm0 = S_MOV_B32 254
90 %3:sreg_32_xm0 = PHI %2, %bb.2, %1, %bb.1
93 # CHECK-LABEL: name: bax
95 # CHECK-NEXT: %2:sreg_32_xm0 = COPY killed %3