From fc740e7924dfa52a39de5f2b8031c2cded0fafb3 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Wed, 16 Nov 2011 00:39:41 +0100 Subject: [PATCH] nv50/ir: fix insertHead and remove for BBs with PHI ops only --- src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp | 13 ++++++++++--- 1 file 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; -- 2.30.2