[Nouveau] [PATCH v2 4/4] nvc0/ir: Handle OP_POPCNT when folding constant expressions
Ilia Mirkin
imirkin at alum.mit.edu
Tue Jun 3 14:01:29 PDT 2014
On Tue, Jun 3, 2014 at 4:58 PM, Tobias Klausmann
<tobias.johannes.klausmann at mni.thm.de> wrote:
> 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;
Do you really need 2 breaks here? Also, funy indentation.
> + }
> 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);
A little overkill -- src(1) already doesn't exist... can get rid of
that, I think.
> + i->op = OP_MOV;
> + i->subOp = 0;
> + }
> + break;
> + }
> default:
> return;
> }
> --
> 1.8.4.5
>
More information about the Nouveau
mailing list