[Mesa-dev] [PATCH] i965/fs: Let sat-prop ignore live ranges if producer already has sat.

Kenneth Graunke kenneth at whitecape.org
Mon Jun 30 00:29:34 PDT 2014


On Sunday, June 29, 2014 11:18:33 PM Matt Turner wrote:
> This sequence (where both x and w are used afterwards) wasn't handled.
> 
>    mul.sat x, y, z
>    ...
>    mov.sat w, x
> 
> We assumed that if x was used after the mov.sat, that we couldn't
> propagate the saturate modifier, but in fact x was already saturated.
> 
> So ignore the live range check if the producing instruction already
> saturates its result. Cuts one instruction from hundreds of TF2 shaders.
> 
> total instructions in shared programs: 1995631 -> 1994951 (-0.03%)
> instructions in affected programs:     155248 -> 154568 (-0.44%)
> ---
>  src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> 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
> 4b5b5ca..079eb2e 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
> @@ -47,8 +47,6 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t
> *block)
> 
>        int src_var = v->live_intervals->var_from_reg(&inst->src[0]);
>        int src_end_ip = v->live_intervals->end[src_var];
> -      if (src_end_ip > ip && !inst->dst.equals(inst->src[0]))
> -         continue;
> 
>        int scan_ip = ip;
>        bool interfered = false;
> @@ -61,10 +59,15 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t
> *block) scan_inst->dst.reg == inst->src[0].reg &&
>               scan_inst->dst.reg_offset == inst->src[0].reg_offset &&
>               !scan_inst->is_partial_write()) {
> -            if (scan_inst->can_do_saturate()) {
> -               scan_inst->saturate = true;
> +            if (scan_inst->saturate) {
>                 inst->saturate = false;
>                 progress = true;
> +            } else if (src_end_ip <= ip || inst->dst.equals(inst->src[0]))
> { +               if (scan_inst->can_do_saturate()) {
> +                  scan_inst->saturate = true;
> +                  inst->saturate = false;
> +                  progress = true;
> +               }
>              }
>              break;
>           }

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140630/38979338/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140630/38979338/attachment-0001.sig>


More information about the mesa-dev mailing list