[Nouveau] [PATCH] nv50/ir: Propagate third immediate src when folding OP_MAD

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Sun Oct 2 17:58:04 UTC 2016


Previously we'd end up with an unnecessary mov for the thirs immediate value.

total instructions in shared programs : 851881 -> 851864 (-0.00%)
total gprs used in shared programs    : 110295 -> 110295 (0.00%)
total local used in shared programs   : 1020 -> 1020 (0.00%)

                local        gpr       inst      bytes
    helped           0           0          17          17
      hurt           0           0           0           0

Suggested-by: Karol Herbst <nouveau at karolherbst.de>
Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 9875738..8bb5cf9 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1008,13 +1008,22 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
       break;
    case OP_MAD:
       if (imm0.isInteger(0)) {
+         ImmediateValue imm1;
          i->setSrc(0, i->getSrc(2));
          i->src(0).mod = i->src(2).mod;
          i->setSrc(1, NULL);
          i->setSrc(2, NULL);
-         i->op = i->src(0).mod.getOp();
-         if (i->op != OP_CVT)
-            i->src(0).mod = 0;
+         if (i->src(0).getImmediate(imm1)) {
+            bld.setPosition(i, false);
+            newi = bld.mkMov(i->getDef(0), bld.mkImm(imm1.reg.data.u64),
+                             i->dType);
+            delete_Instruction(prog, i);
+         }
+         else {
+            i->op = i->src(0).mod.getOp();
+            if (i->op != OP_CVT)
+               i->src(0).mod = 0;
+         }
       } else
       if (i->subOp != NV50_IR_SUBOP_MUL_HIGH &&
           (imm0.isInteger(1) || imm0.isInteger(-1))) {
-- 
2.10.0



More information about the Nouveau mailing list