[Mesa-dev] [PATCH 5/5] nv50/ir: detect when a SLCT is equivalent to a SET

Ilia Mirkin imirkin at alum.mit.edu
Fri Oct 21 06:30:33 UTC 2016


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

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index f6fce44..c555430 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -637,10 +637,25 @@ ConstantFolding::expr(Instruction *i,
       }
       break;
    case OP_SLCT:
-      if (a->data.u32 != b->data.u32)
-         return;
-      res.data.u32 = a->data.u32;
-      break;
+      if (a->data.u32 == b->data.u32) {
+         res.data.u32 = a->data.u32;
+         break;
+      }
+      if ((a->data.u32 == 0 && b->data.u32 == 0xffffffff) ||
+          (b->data.u32 == 0 && a->data.u32 == 0xffffffff)) {
+         bld.setPosition(i, false);
+         CmpInstruction *ci = i->asCmp();
+         i->op = OP_SET;
+         i->dType = TYPE_U32;
+         if (a->data.u32 == 0) {
+            ci->setCond = inverseCondCode(ci->setCond);
+            i->setSrc(1, i->getSrc(0));
+         }
+         i->setSrc(0, i->getSrc(2));
+         i->moveSources(3, -1);
+         ++foldCount;
+      }
+      return;
    case OP_EXTBF: {
       int offset = b->data.u32 & 0xff;
       int width = (b->data.u32 >> 8) & 0xff;
-- 
2.7.3



More information about the mesa-dev mailing list