[Mesa-dev] [PATCH 4/6] nv50/ir: optimize shl(shr(a, c), c) to and(a, ~((1 << c) - 1))

Ilia Mirkin imirkin at alum.mit.edu
Mon Jan 25 19:56:34 PST 2016


Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

I'll run it on my collection on both nvc0 and nv50 to make sure this
doesn't subtly explode somehow, but looks great! I've been meaning to
do this myself but never got around to it.

On Mon, Jan 25, 2016 at 9:57 AM, Karol Herbst <nouveau at karolherbst.de> wrote:
> From: Karol Herbst <git at karolherbst.de>
>
> helps shaders in multiple games
>
> total instructions in shared programs : 1911112 -> 1901958 (-0.48%)
> total gprs used in shared programs    : 251739 -> 251739 (0.00%)
> total local used in shared programs   : 5673 -> 5673 (0.00%)
> total bytes used in shared programs   : 17523440 -> 17440184 (-0.48%)
>
>                 local        gpr       inst      bytes
>     helped           0           0        1387        1387
>       hurt           0           0           0           0
>
> Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 8dc0844..142d9a7 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -1202,6 +1202,14 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
>              i->setSrc(1, bld.loadImm(NULL, imm0.reg.data.u32 + imm1.reg.data.u32));
>           }
>           break;
> +      case OP_SHR:
> +         if (si->src(1).getImmediate(imm1) && imm0.reg.data.u32 == imm1.reg.data.u32) {
> +            bld.setPosition(i, false);
> +            i->op = OP_AND;
> +            i->setSrc(0, si->getSrc(0));
> +            i->setSrc(1, bld.loadImm(NULL, ~((1 << imm0.reg.data.u32) - 1)));
> +         }
> +         break;
>        case OP_MUL:
>           int muls;
>           if (isFloatType(si->dType))
> --
> 2.7.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list