[Nouveau] [PATCH v2 4/4] nvc0/ir: Handle OP_POPCNT when folding constant expressions

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Tue Jun 3 13:58:04 PDT 2014


V2: Add support for a single-argument version of POPCNT for Maxwell (SM5)

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index c497335..19767b4 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -548,6 +548,10 @@ ConstantFolding::expr(Instruction *i,
       }
       break;
    }
+   case OP_POPCNT: {
+         res.data.u32 = util_bitcount(a->data.u32 & b->data.u32); break;
+      break;
+   }
    default:
       return;
    }
@@ -966,6 +970,17 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
       i->subOp = 0;
       break;
    }
+   case OP_POPCNT: {
+      uint32_t res;
+      if (!i->srcExists(1)) {
+         res = util_bitcount(imm0.reg.data.u32);
+         i->setSrc(0, new_ImmediateValue(i->bb->getProgram(), res));
+         i->setSrc(1, NULL);
+         i->op = OP_MOV;
+         i->subOp = 0;
+      }
+      break;
+   }
    default:
       return;
    }
-- 
1.8.4.5



More information about the Nouveau mailing list