[Mesa-dev] [PATCH] nv50/ir: clean up saturated values immediately

Ilia Mirkin imirkin at alum.mit.edu
Sat Aug 12 17:45:21 UTC 2017


Since we don't iterate to a fixed point, we can end up in situations
where we have a SAT instruction + a long immediate. This is not legal.
However since it's immediately computable, just run unary straight away
to handle the situation.

Fixes: 24a799ad35a82 ("nv50/ir: fix ConstantFolding with saturation")
Reported-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index cfc0dfc53cf..6584f3b1152 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -727,7 +727,9 @@ ConstantFolding::expr(Instruction *i,
       // Leave PFETCH alone... we just folded its 2 args into 1.
       break;
    default:
-      i->op = i->saturate ? OP_SAT : OP_MOV; /* SAT handled by unary() */
+      i->op = i->saturate ? OP_SAT : OP_MOV;
+      if (i->saturate)
+         unary(i, *i->getSrc(0)->asImm());
       break;
    }
    i->subOp = 0;
@@ -1515,6 +1517,8 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
    if (newi->op == OP_MOV && newi->saturate) {
       newi->saturate = 0;
       newi->op = OP_SAT;
+      if (newi->getSrc(0)->asImm())
+         unary(newi, *newi->getSrc(0)->asImm());
    }
 
    if (newi->op != op)
-- 
2.13.0



More information about the mesa-dev mailing list