Mesa (master): nvc0/ir: Handle OP_POPCNT when folding constant expressions

Ilia Mirkin imirkin at kemper.freedesktop.org
Fri Jun 6 04:07:24 UTC 2014


Module: Mesa
Branch: master
Commit: 4f4e9ba1661528bed8e956a4931ae154e6612824
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f4e9ba1661528bed8e956a4931ae154e6612824

Author: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
Date:   Wed Jun  4 00:35:50 2014 +0200

nvc0/ir: Handle OP_POPCNT when folding constant expressions

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
[imirkin: make sure to only fold 1-arg popcnt in opnd]
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

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

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index a91d698..b89da43 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -540,6 +540,9 @@ ConstantFolding::expr(Instruction *i,
       }
       break;
    }
+   case OP_POPCNT:
+      res.data.u32 = util_bitcount(a->data.u32 & b->data.u32);
+      break;
    default:
       return;
    }
@@ -957,6 +960,16 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
       i->subOp = 0;
       break;
    }
+   case OP_POPCNT: {
+      // Only deal with 1-arg POPCNT here
+      if (i->srcExists(1))
+         break;
+      uint32_t res = util_bitcount(imm0.reg.data.u32);
+      i->setSrc(0, new_ImmediateValue(i->bb->getProgram(), res));
+      i->setSrc(1, NULL);
+      i->op = OP_MOV;
+      break;
+   }
    default:
       return;
    }




More information about the mesa-commit mailing list