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

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Sep 13 19:36:10 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 246cdff..284f187 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1070,7 +1070,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.3



More information about the mesa-dev mailing list