[Mesa-dev] [PATCH] nv50/ir: optimize sub(a, 0) to a

Pierre Moreau pierre.morrow at free.fr
Thu Oct 6 13:38:40 UTC 2016


Reviewed-by: Pierre Moreau <pierre.morrow at free.fr>

On 12:36 am - Oct 06 2016, Karol Herbst wrote:
> helped some ue4 demos and divinity OS shaders
> 
> total instructions in shared programs : 2818674 -> 2818606 (-0.00%)
> total gprs used in shared programs    : 379273 -> 379273 (0.00%)
> total local used in shared programs   : 9505 -> 9505 (0.00%)
> total bytes used in shared programs   : 25837792 -> 25837192 (-0.00%)
> 
>                 local        gpr       inst      bytes
>     helped           0           0          33          33
>       hurt           0           0           0           0
> 
> Signed-off-by: Karol Herbst <karolherbst at gmail.com>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 3 +++
>  1 file changed, 3 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..1c71155 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
> @@ -1037,12 +1037,15 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
>        }
>        break;
>     case OP_ADD:
> +   case OP_SUB:
>        if (i->usesFlags())
>           break;
>        if (imm0.isInteger(0)) {
>           if (s == 0) {
>              i->setSrc(0, i->getSrc(1));
>              i->src(0).mod = i->src(1).mod;
> +            if (i->op == OP_SUB)
> +               i->src(0).mod = i->src(0).mod ^ Modifier(NV50_IR_MOD_NEG);
>           }
>           i->setSrc(1, NULL);
>           i->op = i->src(0).mod.getOp();
> -- 
> 2.10.0
> 
> _______________________________________________
> 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