From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH] drm/i915: Simplify mmio_reg_cmp
Date: Fri, 3 Nov 2017 13:10:42 +0000 [thread overview]
Message-ID: <20171103131042.746-1-tvrtko.ursulin@linux.intel.com> (raw)
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
next reply other threads:[~2017-11-03 13:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-03 13:10 Tvrtko Ursulin [this message]
2017-11-03 13:18 ` [PATCH] drm/i915: Simplify mmio_reg_cmp Chris Wilson
2017-11-03 13:43 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-11-03 14:40 ` ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171103131042.746-1-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--cc=Intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).