[Mesa-dev] [PATCH 6/8] nv50/ir: ensure that the constraint mov is placed above flow control

Ilia Mirkin imirkin at alum.mit.edu
Wed Dec 5 05:29:27 UTC 2018


This is tickled by the Maxwell lowering logic for shared floating point
add, but it could potentially come up in other ways too.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---

Note that this may depend slightly on a local patch. However the overall
idea remains entirely the same.

 src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
index 8d0d66cd212..9b7f46e1e86 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
@@ -442,7 +442,15 @@ RegAlloc::PhiMovesPass::visit(BasicBlock *bb)
          Instruction *mov = new_Instruction(func, OP_MOV, typeOfSize(tmp->reg.size));
          mov->setSrc(0, phi->getSrc(i));
          mov->setDef(0, tmp);
-         pb->insertBefore(pb->getExit(), mov);
+
+         // A BB may have multiple flow instructions at the end. We have to
+         // make sure that the mov goes in before the relevant jump.
+         Instruction *jump = pb->getExit();
+         while (jump->asFlow()->target.bb != bb) {
+            assert(jump->prev->asFlow());
+            jump = jump->prev;
+         }
+         pb->insertBefore(jump, mov);
 
          phi->setSrc(i, tmp);
       }
-- 
2.18.1



More information about the mesa-dev mailing list