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

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Tue Jun 3 15:35:50 PDT 2014


Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
V2: Add support for a single-argument version of POPCNT for Maxwell (SM5)
V3: Clean up a bit more

 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index e4d91d7..8dde7c1 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -544,6 +544,8 @@ ConstantFolding::expr(Instruction *i,
       }
       break;
    }
+   case OP_POPCNT: res.data.u32 = util_bitcount(a->data.u32 & b->data.u32);
+      break;
    default:
       return;
    }
@@ -961,6 +963,15 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
       i->subOp = 0;
       break;
    }
+   case OP_POPCNT: {
+      uint32_t res;
+      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