From: Christoph Bumiller Date: Tue, 15 Nov 2011 23:39:41 +0000 (+0100) Subject: nv50/ir: fix insertHead and remove for BBs with PHI ops only X-Git-Tag: mesa-9.0~2488 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc740e7924dfa52a39de5f2b8031c2cded0fafb3;p=platform%2Fupstream%2Fmesa.git nv50/ir: fix insertHead and remove for BBs with PHI ops only --- diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp index 83938ed..fb41888 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;