[Mesa-dev] [PATCH 4/5] i965/fs: Allow saturate propagation to propagate negations into MADs.

Ilia Mirkin imirkin at alum.mit.edu
Tue Feb 23 00:39:00 UTC 2016


On Mon, Feb 22, 2016 at 7:13 PM, Matt Turner <mattst88 at gmail.com> wrote:

Unless there's something unexpected going on, let's say

src0 = 0, src1 = 0, src2 = -0.5

> Allows us to transform
>
>    mad      res  src0   src1   src2

res = -0.5

>    mov.sat  dst  -res

dst = 0.5

>
> into
>
>    mad.sat  dst  -src0 -src1   src2

-0 * -0 + -0.5 = -0.5
dst = 0

I don't think those two are equivalent... unless you can stick a neg
on src2 as well.

>
> instructions in affected programs: 3712 -> 3688 (-0.65%)
> helped: 24
> ---
>  src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
> index 7c82509..dc2b0c8 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
> @@ -86,6 +86,10 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
>                       if (scan_inst->opcode == BRW_OPCODE_MUL) {
>                          scan_inst->src[0].negate = !scan_inst->src[0].negate;
>                          inst->src[0].negate = false;
> +                     } else if (scan_inst->opcode == BRW_OPCODE_MAD) {
> +                        scan_inst->src[0].negate = !scan_inst->src[0].negate;
> +                        scan_inst->src[1].negate = !scan_inst->src[1].negate;
> +                        inst->src[0].negate = false;
>                       } else if (scan_inst->opcode == BRW_OPCODE_ADD) {
>                          if (scan_inst->src[1].file == IMM) {
>                             if (!brw_negate_immediate(scan_inst->src[1].type,
> --
> 2.4.10
>
> _______________________________________________
> 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