[Mesa-dev] [PATCH 1/2] i965: Optimize brw_inst_bits() and brw_compact_inst_bits().

Kenneth Graunke kenneth at whitecape.org
Tue Aug 11 14:02:28 PDT 2015


On Tuesday, August 11, 2015 01:29:46 PM Matt Turner wrote:
> Cuts about 1k of .text.
> 
>    text     data      bss      dec      hex  filename
> 5018165   197160    27672  5242997   500075  i965_dri.so before
> 5017141   197160    27672  5241973   4ffc75  i965_dri.so after
> ---
>  src/mesa/drivers/dri/i965/brw_inst.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_inst.h b/src/mesa/drivers/dri/i965/brw_inst.h
> index 7a8c210..5feea38 100644
> --- a/src/mesa/drivers/dri/i965/brw_inst.h
> +++ b/src/mesa/drivers/dri/i965/brw_inst.h
> @@ -683,9 +683,9 @@ brw_inst_bits(const brw_inst *inst, unsigned high, unsigned low)
>     high %= 64;
>     low %= 64;
>  
> -   const uint64_t mask = (((1ull << (high - low + 1)) - 1) << low);
> +   const uint64_t mask = ((1ull << (high - low + 1)) - 1);

Every + line in this patch has bonus parens around the entire
expression, which are unnecessary - personally, I'd drop them.
But that's a stylistic preference, and it's totally your call.

Both patches are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Nice find!

>  
> -   return (inst->data[word] & mask) >> low;
> +   return ((inst->data[word] >> low) & mask);
>  }
>  
>  /**
> @@ -731,9 +731,9 @@ typedef struct {
>  static inline unsigned
>  brw_compact_inst_bits(brw_compact_inst *inst, unsigned high, unsigned low)
>  {
> -   const uint64_t mask = (((1ull << (high - low + 1)) - 1) << low);
> +   const uint64_t mask = ((1ull << (high - low + 1)) - 1);
>  
> -   return (inst->data & mask) >> low;
> +   return ((inst->data >> low) & mask);
>  }
>  
>  /**
> 
-------------- 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/20150811/d166db29/attachment.sig>


More information about the mesa-dev mailing list