[Mesa-dev] [PATCH 1/6] nv50/ir: enable PostRaConstantFolding for [c0, f0)

Karol Herbst nouveau at karolherbst.de
Mon Jan 25 06:57:48 PST 2016


From: Karol Herbst <git at karolherbst.de>

helps shaders in multiple games

total instructions in shared programs : 1926020 -> 1922267 (-0.19%)
total gprs used in shared programs    : 251878 -> 251878 (0.00%)
total local used in shared programs   : 5673 -> 5673 (0.00%)
total bytes used in shared programs   : 17659256 -> 17625496 (-0.19%)

                local        gpr       inst      bytes
    helped           0           0        2082        2082
      hurt           0           0           0           0

Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 95e9fdf..bfec130 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -2883,15 +2883,17 @@ NV50PostRaConstantFolding::visit(BasicBlock *bb)
             def = def->getSrc(0)->getInsn();
          if (def && def->op == OP_MOV && def->src(0).getFile() == FILE_IMMEDIATE) {
             vtmp = i->getSrc(1);
-            if (isFloatType(i->sType)) {
+            if (typeSizeof(i->sType) > 2) {
                i->setSrc(1, def->getSrc(0));
             } else {
                ImmediateValue val;
                bool ret = def->src(0).getImmediate(val);
                assert(ret);
-               if (i->getSrc(1)->reg.data.id & 1)
-                  val.reg.data.u32 >>= 16;
-               val.reg.data.u32 &= 0xffff;
+               if (typeSizeof(i->sType) == 2) {
+                  if (i->getSrc(1)->reg.data.id & 1)
+                     val.reg.data.u32 >>= 16;
+                  val.reg.data.u32 &= 0xffff;
+               }
                i->setSrc(1, new_ImmediateValue(bb->getProgram(), val.reg.data.u32));
             }
 
@@ -3325,7 +3327,7 @@ bool
 Program::optimizePostRA(int level)
 {
    RUN_PASS(2, FlatteningPass, run);
-   if (getTarget()->getChipset() < 0xc0)
+   if (getTarget()->getChipset() < 0xf0)
       RUN_PASS(2, NV50PostRaConstantFolding, run);
 
    return true;
-- 
2.7.0



More information about the mesa-dev mailing list