[Mesa-dev] [PATCH 3/4] nvc0/ir: Handle OP_POPCNT when folding constant expressions
Ilia Mirkin
imirkin at alum.mit.edu
Thu May 29 12:53:41 PDT 2014
On Thu, May 29, 2014 at 3:43 PM, Tobias Klausmann
<tobias.johannes.klausmann at mni.thm.de> wrote:
> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
> ---
> src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 93f7c2a..68b9a6d 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -546,6 +546,16 @@ ConstantFolding::expr(Instruction *i,
> }
> break;
> }
> + case OP_POPCNT: {
> + switch (i->dType) {
> + case TYPE_S32:
> + case TYPE_U32:
> + res.data.u32 = util_bitcount(a->data.u32 & b->data.u32); break;
> + default:
> + return;
> + }
> + break;
> + }
Why does the data type matter? I think you can handle this like AND is
handled -- just always do it.
Also, please add support for a single-argument version of POPCNT. This
will happen as a result of lowering for sm50 (maxwell), for which it's
a 1-arg instruction. Basically you need to add a case to opnd() which
checks that there's only one argument and does it accordingly. [The
existing function assumes a float op, and it'd be a pain to modify
it.]
> default:
> return;
> }
> --
> 1.8.4.5
>
More information about the mesa-dev
mailing list