[Mesa-dev] [PATCH 16/19] i965/fs: Perform CSE on load_payload instructions if it's not a copy.

Kenneth Graunke kenneth at whitecape.org
Sun Jun 1 00:04:35 PDT 2014


On Friday, April 18, 2014 11:56:52 AM Matt Turner wrote:
> Since CSE creates instructions, if we let CSE generate things register
> coalescing can't remove, bad things will happen. Only let CSE combine
> non-copy load_payloads.
> 
> E.g., allow CSE to handle this
> 
>    load_payload vgrf4+0, vgrf5, vgrf6
> 
> but not this
> 
>    load_payload vgrf4+0, vgrf5+0, vgrf5+1
> ---
>  src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
> index 44f1fe4..dc80968 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
> @@ -43,6 +43,22 @@ struct aeb_entry : public exec_node {
>  }
>  
>  static bool
> +is_copy_payload(const fs_inst *inst)
> +{
> +   const int reg = inst->src[0].reg;
> +   if (inst->src[0].reg_offset != 0)
> +      return false;
> +
> +   for (int i = 1; i < inst->sources; i++) {
> +      if (inst->src[i].reg != reg ||
> +          inst->src[i].reg_offset != i) {
> +         return false;
> +      }
> +   }
> +   return true;
> +}

This code is duplicated from patch 15.  Why not make it a method of fs_inst 
with an additional "if (inst->opcode != SHADER_OPCODE_LOAD_PAYLOAD) return 
false" check?  Or, share it somehow...it seems useful enough.

> +
> +static bool
>  is_expression(const fs_inst *const inst)
>  {
>     switch (inst->opcode) {
> @@ -73,6 +89,8 @@ is_expression(const fs_inst *const inst)
>     case FS_OPCODE_CINTERP:
>     case FS_OPCODE_LINTERP:
>        return true;
> +   case SHADER_OPCODE_LOAD_PAYLOAD:
> +      return !is_copy_payload(inst);
>     default:
>        return false;
>     }
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140601/92d36b66/attachment.sig>


More information about the mesa-dev mailing list