1 # RUN: llc -mtriple amdgcn -run-pass livevars -run-pass phi-node-elimination -o - %s | FileCheck %s
2 # RUN: llc -mtriple amdgcn --passes='require<live-vars>,phi-node-elimination' -o - %s | FileCheck %s
4 ################################################################################
5 # This test used to hit an assert in PHIElimination:
6 # PHIElimination::LowerPHINode(llvm::MachineBasicBlock&, llvm::MachineBasicBlock::iterator): Assertion `KillInst->readsRegister(SrcReg) && "Cannot find kill instruction"'
10 tracksRegLiveness: true
13 S_CBRANCH_SCC0 %bb.2, implicit undef $scc
16 %1:sreg_32_xm0 = S_MOV_B32 255
20 %2:sreg_32_xm0 = S_MOV_B32 254
23 dead %3:sreg_32_xm0 = PHI undef %2, %bb.2, undef %1, %bb.1
24 %4:sreg_32_xm0 = PHI %2, %bb.2, %1, %bb.1
28 # CHECK-LABEL: name: foo
30 # CHECK-NEXT: dead %2:sreg_32_xm0 = IMPLICIT_DEF
31 # CHECK-NEXT: %3:sreg_32_xm0 = COPY killed %4
32 # CHECK-NEXT: S_NOP 0, implicit killed %3
35 ################################################################################
36 # Similar test as above, but with swapped order for the PHI nodes.
37 # With this PHI node order we did not hit the assert, but we used to get
40 # dead %3:sreg_32_xm0 = COPY killed %4
41 # %2:sreg_32_xm0 = COPY %4
42 # S_NOP 0, implicit killed %2
44 # which looks weird regarding killed flags for %4.
48 tracksRegLiveness: true
51 S_CBRANCH_SCC0 %bb.2, implicit undef $scc
54 %1:sreg_32_xm0 = S_MOV_B32 255
58 %2:sreg_32_xm0 = S_MOV_B32 254
61 %4:sreg_32_xm0 = PHI %2, %bb.2, %1, %bb.1
62 dead %3:sreg_32_xm0 = PHI undef %2, %bb.2, undef %1, %bb.1
66 # CHECK-LABEL: name: bar
68 # CHECK-NEXT: dead %3:sreg_32_xm0 = IMPLICIT_DEF
69 # CHECK-NEXT: %2:sreg_32_xm0 = COPY killed %4
70 # CHECK-NEXT: S_NOP 0, implicit killed %2
73 # The following test crashes in phi-elimination hooks.
78 tracksRegLiveness: true
81 S_CBRANCH_SCC0 %bb.2, implicit undef $scc
84 %1:sreg_32_xm0 = S_MOV_B32 255
88 %2:sreg_32_xm0 = S_MOV_B32 254
91 %3:sreg_32_xm0 = PHI %2, %bb.2, %1, %bb.1
94 # CHECK-LABEL: name: bax
96 # CHECK-NEXT: %2:sreg_32_xm0 = COPY killed %3