[Mesa-dev] [PATCH 13/17] i965/fs: Allow propagation of instructions with saturate flag to sel

Matt Turner mattst88 at gmail.com
Tue Aug 19 19:30:55 PDT 2014


On Mon, Aug 18, 2014 at 5:17 AM, Abdiel Janulgue
<abdiel.janulgue at linux.intel.com> wrote:
> When sel conditon is bounded within 0 and 1.0. This allows code as:
>         mov.sat a b
>         sel.ge  dst a 0.25F
>
> To be propagated as:
>         sel.ge.sat dst b 0.25F
>
> v3: Syntax clarifications in inst->saturate assignment (Matt Turner)
>
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> ---
>  src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
> index 09f51bc..7e4eab7 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
> @@ -43,6 +43,7 @@ struct acp_entry : public exec_node {
>     fs_reg dst;
>     fs_reg src;
>     enum opcode opcode;
> +   bool saturate;
>  };
>
>  struct block_data {
> @@ -347,11 +348,26 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
>        return false;
>     }
>
> +   if (entry->saturate) {
> +      switch(inst->opcode) {
> +      case BRW_OPCODE_SEL:
> +         if (inst->src[1].file != IMM ||
> +             inst->src[1].fixed_hw_reg.dw1.f < 0.0 ||
> +             inst->src[1].fixed_hw_reg.dw1.f > 1.0) {
> +            return false;

SEL can use conditional mod (for min/max) but it can also be
predicated. I think you also need to return false if
inst->conditional_mod == BRW_CONDITIONAL_NONE. With that added,

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list