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

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Jul 19 10:30:20 UTC 2016


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

v2: - use moveSources()
    - allow ADD3 -> ADD when srcFlags is set

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 7 ++++++-
 1 file changed, 6 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 ec6418b..57c8ea8 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1036,7 +1036,12 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
             i->src(0).mod = Modifier(0);
       }
       break;
-
+   case OP_ADD3:
+      if (imm0.isInteger(0)) {
+         i->op = OP_ADD;
+         i->moveSources(s + 1, -1);
+      }
+      break;
    case OP_DIV:
       if (s != 1 || (i->dType != TYPE_S32 && i->dType != TYPE_U32))
          break;
-- 
2.9.0



More information about the mesa-dev mailing list