intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Simplify mmio_reg_cmp
@ 2017-11-03 13:10 Tvrtko Ursulin
  2017-11-03 13:18 ` Chris Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tvrtko Ursulin @ 2017-11-03 13:10 UTC (permalink / raw)
  To: Intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

If we remove one condition from the comparison mmio_reg_cmp becomes
smaller and compiler can fully inline it. This grows the text a little
bit but avoids the function call.

We depend, and verify, on the fact that addresses of mmio registers fit
in a signed integer.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/intel_uncore.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 0a6d952a2df1..a68a9960c928 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -865,12 +865,9 @@ static int mmio_reg_cmp(u32 key, const i915_reg_t *reg)
 {
 	u32 offset = i915_mmio_reg_offset(*reg);
 
-	if (key < offset)
-		return -1;
-	else if (key > offset)
-		return 1;
-	else
-		return 0;
+	GEM_BUG_ON(key > (u32)INT_MAX || offset > (u32)INT_MAX);
+
+	return (int)key - (int)offset;
 }
 
 static bool is_gen8_shadowed(u32 offset)
-- 
2.9.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-03 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-03 13:10 [PATCH] drm/i915: Simplify mmio_reg_cmp Tvrtko Ursulin
2017-11-03 13:18 ` Chris Wilson
2017-11-03 13:43 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-11-03 14:40 ` ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).