[Mesa-dev] [PATCH 6/8] nv50/ir: optimize ADD3(d, 0x0, b, c) to ADD(d, b, c)

Ilia Mirkin imirkin at alum.mit.edu
Thu Jun 30 22:44:45 UTC 2016


If moveSources doesn't move modifiers, we have a serious problem.
However it looks like it does:

void
Instruction::setSrc(int s, const ValueRef& ref)
{
   setSrc(s, ref.get());
   srcs[s].mod = ref.mod;
}

which is what moveSources calls.


On Thu, Jun 30, 2016 at 6:26 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> And ADD3(d, a, 0x0, c) to ADD(d, a, c) as well.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> index 1cf1fa3..517f779 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -1032,7 +1032,17 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
>              i->src(0).mod = Modifier(0);
>        }
>        break;
> -
> +   case OP_ADD3:
> +      if (i->usesFlags())
> +         break;

Why? ADD can produce/consume a flag just fine.

> +      if (imm0.isInteger(0)) {
> +         i->op = OP_ADD;
> +         for (int k = s; k < 2; k++) {
> +            i->setSrc(k, i->getSrc(k + 1));
> +            i->src(k).mod = i->src(k + 1).mod;
> +         }

aka

i->moveSources(s + 1, -1) ?

> +      }
> +      break;
>     case OP_DIV:
>        if (s != 1 || (i->dType != TYPE_S32 && i->dType != TYPE_U32))
>           break;
> --
> 2.8.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list