[Mesa-dev] [PATCH 1/6] nv50/ir: enable PostRaConstantFolding for [c0, f0)

Ilia Mirkin imirkin at alum.mit.edu
Mon Jan 25 17:37:52 PST 2016


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 : 1926020 -> 1922267 (-0.19%)
> total gprs used in shared programs    : 251878 -> 251878 (0.00%)
> total local used in shared programs   : 5673 -> 5673 (0.00%)
> total bytes used in shared programs   : 17659256 -> 17625496 (-0.19%)
>
>                 local        gpr       inst      bytes
>     helped           0           0        2082        2082
>       hurt           0           0           0           0
>
> Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 95e9fdf..bfec130 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -2883,15 +2883,17 @@ NV50PostRaConstantFolding::visit(BasicBlock *bb)
>              def = def->getSrc(0)->getInsn();
>           if (def && def->op == OP_MOV && def->src(0).getFile() == FILE_IMMEDIATE) {
>              vtmp = i->getSrc(1);
> -            if (isFloatType(i->sType)) {
> +            if (typeSizeof(i->sType) > 2) {
>                 i->setSrc(1, def->getSrc(0));
>              } else {
>                 ImmediateValue val;
>                 bool ret = def->src(0).getImmediate(val);
>                 assert(ret);
> -               if (i->getSrc(1)->reg.data.id & 1)
> -                  val.reg.data.u32 >>= 16;
> -               val.reg.data.u32 &= 0xffff;
> +               if (typeSizeof(i->sType) == 2) {

Why are you checking this again here? I think this path is guaranteed
to be the nv50 one with the u16's

> +                  if (i->getSrc(1)->reg.data.id & 1)
> +                     val.reg.data.u32 >>= 16;
> +                  val.reg.data.u32 &= 0xffff;
> +               }
>                 i->setSrc(1, new_ImmediateValue(bb->getProgram(), val.reg.data.u32));
>              }
>
> @@ -3325,7 +3327,7 @@ bool
>  Program::optimizePostRA(int level)
>  {
>     RUN_PASS(2, FlatteningPass, run);
> -   if (getTarget()->getChipset() < 0xc0)
> +   if (getTarget()->getChipset() < 0xf0)

Why 0xf0? First off, GK20A is 0xea and is the same SM35 ISA as 0xf0,
we have various defines for these. More importantly, does SM35 (or
SM50) lift some of the restrictions on immediates s.t. this would no
longer be desirable? Check in envydis. Also please check that the
emitters are capable of handling this properly.

Thanks,

  -ilia


More information about the mesa-dev mailing list