[Mesa-dev] [PATCH 6/8] nv50/ir: optimize ADD3(d, 0x0, b, c) to ADD(d, b, c)

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Jun 30 22:26:56 UTC 2016


And ADD3(d, a, 0x0, c) to ADD(d, a, c) as well.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 12 +++++++++++-
 1 file changed, 11 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 1cf1fa3..517f779 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1032,7 +1032,17 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
             i->src(0).mod = Modifier(0);
       }
       break;
-
+   case OP_ADD3:
+      if (i->usesFlags())
+         break;
+      if (imm0.isInteger(0)) {
+         i->op = OP_ADD;
+         for (int k = s; k < 2; k++) {
+            i->setSrc(k, i->getSrc(k + 1));
+            i->src(k).mod = i->src(k + 1).mod;
+         }
+      }
+      break;
    case OP_DIV:
       if (s != 1 || (i->dType != TYPE_S32 && i->dType != TYPE_U32))
          break;
-- 
2.8.3



More information about the mesa-dev mailing list