[Intel-gfx] [PATCH v2 4/6] drm/i915: Reduce arithmetic operations during cmd parser lookup

Ville Syrjälä ville.syrjala at linux.intel.com
Fri Nov 20 07:02:51 PST 2015


On Fri, Nov 20, 2015 at 10:55:59AM +0000, Chris Wilson wrote:
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_cmd_parser.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
> index 4a3e90b042c5..cfd07bfe6e75 100644
> --- a/drivers/gpu/drm/i915/i915_cmd_parser.c
> +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
> @@ -806,10 +806,7 @@ find_cmd_in_table(struct intel_engine_cs *ring,
>  	hash_for_each_possible(ring->cmd_hash, desc_node, node,
>  			       cmd_header & CMD_HASH_MASK) {
>  		const struct drm_i915_cmd_descriptor *desc = desc_node->desc;
> -		u32 masked_cmd = desc->cmd.mask & cmd_header;
> -		u32 masked_value = desc->cmd.value & desc->cmd.mask;
> -
> -		if (masked_cmd == masked_value)
> +		if (((cmd_header ^ desc->cmd.value) & desc->cmd.mask) == 0)

Hmm. '(a & m) == (b & m)' vs '((a ^ b) & m) == 0'.

So two & vs. one ^ and one &. Is that an improvement, dunno.

At least the result should be the same, so based on that:
Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

>  			return desc;
>  	}
>  
> -- 
> 2.6.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC


More information about the Intel-gfx mailing list