nv50/ir: fix insertHead and remove for BBs with PHI ops only
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Tue, 15 Nov 2011 23:39:41 +0000 (00:39 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 19:54:00 +0000 (21:54 +0200)
src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp

index 83938edc389413dd1f1385fe300c97cdeba3e0c7..fb4188870a67733e92307fdab281982f8dcb9463 100644 (file)
@@ -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;