diff mbox

[v2,4/6] drm/i915: Reduce arithmetic operations during cmd parser lookup

Message ID 1448016961-25331-5-git-send-email-chris@chris-wilson.co.uk
State New, archived
Headers show

Commit Message

Chris Wilson Nov. 20, 2015, 10:55 a.m. UTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Ville Syrjala Nov. 20, 2015, 3:02 p.m. UTC | #1
On Fri, Nov 20, 2015 at 10:55:59AM +0000, Chris Wilson wrote:
> Signed-off-by: Chris Wilson <chris@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@linux.intel.com>

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

Patch

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)
 			return desc;
 	}