[Mesa-dev] [PATCH] nv50/ir: make a copy of tex src if it's referenced multiple times
Ilia Mirkin
imirkin at alum.mit.edu
Tue Apr 10 02:23:32 UTC 2018
For nv50 we coalesce the srcs and defs into a single node (some ops
can't take a separate src and dst, while others can only handle one reg
in the short encoding mode).
[Side-note: the ops for which there is an encoding that can take a src
should instead use the RA's register preference facility.]
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
index 3a0e56e1385..f5ce1b4a0b0 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp
@@ -2216,6 +2216,16 @@ RegAlloc::InsertConstraintsPass::texConstraintNV50(TexInstruction *tex)
for (c = 0; tex->srcExists(c) || tex->defExists(c); ++c) {
if (!tex->srcExists(c))
tex->setSrc(c, new_LValue(func, tex->getSrc(0)->asLValue()));
+ else if (tex->getSrc(c)->refCount() > 1) {
+ // Disconnect source from the single definition since it's about to
+ // get merged with the defs (due to JOIN_MASK_TEX).
+ LValue *lval = new_LValue(func, FILE_GPR);
+ Instruction *mov = new_Instruction(func, OP_MOV, TYPE_U32);
+ mov->setSrc(0, tex->getSrc(c));
+ mov->setDef(0, lval);
+ tex->bb->insertBefore(tex, mov);
+ tex->setSrc(c, lval);
+ }
if (!tex->defExists(c))
tex->setDef(c, new_LValue(func, tex->getDef(0)->asLValue()));
}
--
2.16.1
More information about the mesa-dev
mailing list