Quoting Tvrtko Ursulin (2017-11-03 13:10:42) > From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > > 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. Ok. I was thinking it would be simpler if we around the wraparound comparison, but we don't want that here. > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > --- > 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) static inline then? > { > 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); GEM_BUG_ON((key | offset) > INT_MAX); ? Casting the INT_MAX to (u32) here is implicit. > + > + return (int)key - (int)offset; Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx