[Nouveau] [PATCH v2] nv50/ir: constant fold OP_SPLIT

Ilia Mirkin imirkin at alum.mit.edu
Fri Sep 30 21:57:17 UTC 2016


On Fri, Sep 30, 2016 at 5:50 PM, Tobias Klausmann
<tobias.johannes.klausmann at mni.thm.de> wrote:
> Split the source immediate value into two new values and create OP_MOV
> instructions the two newly created values.
>
> V2: get rid of special cases
>
> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 9875738..d56b057 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -932,6 +932,22 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
>     Instruction *newi = i;
>
>     switch (i->op) {
> +   case OP_SPLIT: {
> +      uint8_t size = typeSizeof(i->dType);
> +      DataType type = typeOfSize(size / 2, isFloatType(i->dType),
> +                                 isSignedType(i->dType));

Er wait, sorry, I might have confused matters here...

Why do you need to compute type at all? Why not just reuse i->dType?

> +      if (likely(type != TYPE_NONE)) {
> +         uint64_t val = imm0.reg.data.u64;
> +         uint16_t shift = size * 8;
> +         bld.setPosition(i, false);
> +         for (int8_t d = 0; i->defExists(d); ++d) {
> +            bld.mkMov(i->getDef(d), bld.mkImm(val & ((1 << shift) - 1)), type);

1ULL

> +            val >>= shift;
> +         }
> +         delete_Instruction(prog, i);
> +      }
> +   }
> +   break;
>     case OP_MUL:
>        if (i->dType == TYPE_F32)
>           tryCollapseChainedMULs(i, s, imm0);
> --
> 2.10.0
>
> _______________________________________________
> Nouveau mailing list
> Nouveau at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau


More information about the Nouveau mailing list