[Mesa-dev] [PATCH] nv50/ir: fold shl + mul with immediates

Ilia Mirkin imirkin at alum.mit.edu
Fri Dec 4 14:27:45 PST 2015


On SM35 this gives:

total instructions in shared programs : 6185058 -> 6181090 (-0.06%)
total gprs used in shared programs    : 910722 -> 910722 (0.00%)
total local used in shared programs   : 39072 -> 39072 (0.00%)

                local        gpr       inst      bytes
    helped           0           0        2137        2137
      hurt           0           0           0           0

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 6dec208..9760128 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1191,6 +1191,14 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
             i->setSrc(1, bld.loadImm(NULL, imm0.reg.data.u32 + imm1.reg.data.u32));
          }
          break;
+      case OP_MUL:
+         if (!isFloatType(si->dType) && si->src(1).getImmediate(imm1)) {
+            bld.setPosition(i, false);
+            i->op = OP_MUL;
+            i->setSrc(0, si->getSrc(0));
+            i->setSrc(1, bld.loadImm(NULL, (1 << imm0.reg.data.u32) * imm1.reg.data.u32));
+         }
+         break;
       case OP_SUB:
       case OP_ADD:
          int adds;
-- 
2.4.10



More information about the mesa-dev mailing list