diff options
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp index 83938edc389..fb4188870a6 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp @@ -104,7 +104,7 @@ BasicBlock::insertHead(Instruction *inst) insertBefore(entry, inst); } else { if (phi) { - insertAfter(phi, inst); + insertAfter(exit, inst); // after last phi } else { assert(!exit); entry = exit = inst; @@ -211,8 +211,15 @@ BasicBlock::remove(Instruction *insn) else exit = insn->prev; - if (insn == entry) - entry = insn->next ? insn->next : insn->prev; + if (insn == entry) { + if (insn->next) + entry = insn->next; + else + if (insn->prev && insn->prev->op != OP_PHI) + entry = insn->prev; + else + entry = NULL; + } if (insn == phi) phi = (insn->next && insn->next->op == OP_PHI) ? insn->next : 0; |