nv50/ir/ra: make sure all used function inputs get assigned a reg
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 27 Feb 2013 20:08:57 +0000 (21:08 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Tue, 12 Mar 2013 11:55:34 +0000 (12:55 +0100)
A live range [0, 0) counts as empty. For function inputs this can
be a problem, so insert a nop at the beginning to make it [0, 1).
This is a bit of a hack but also the most simple solution.

src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp

index 5e5255f..e0fea4b 100644 (file)
@@ -1586,6 +1586,13 @@ RegAlloc::execFunc()
    unsigned int i, retries;
    bool ret;
 
+   if (!func->ins.empty()) {
+      // Insert a nop at the entry so inputs only used by the first instruction
+      // don't count as having an empty live range.
+      Instruction *nop = new_Instruction(func, OP_NOP, TYPE_NONE);
+      BasicBlock::get(func->cfg.getRoot())->insertHead(nop);
+   }
+
    ret = insertConstr.exec(func);
    if (!ret)
       goto out;