lkml.org 
[lkml]   [2010]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] introduce ptr_diff()
> I'm not sure the price is so high.  I googled around and came across
> http://mdfs.net/Docs/Comp/ARM/Cookbook/cook3 (section 3.3). Dividing by
> 2^n, (2^n + 2^m) or (2^n - 2^m) can be done using a small series of adds
> and subtractions (important on ARM as it had no divide instruction at
> the time). Most structures are going to be of one of these sizes ...
> and in particular, struct page is 56 bytes in my config, which is 64 - 8.
> Maybe sparse needs to be taught that dividing by 2^n [+-] 2^m is cheap
> enough to not warn about.

Usually you can just use x/n = x*(1/n) and generate *(1/n) with 1/n
being computed at compile time. Multiplications are fast in hardware.

gcc only does that when -Os is not set though (friends don't let friends
compile with -Os...)

-Andi

--
ak@linux.intel.com -- Speaking for myself only.


\
 
 \ /
  Last update: 2010-08-20 15:01    [from the cache]
©2003-2011 Jasper Spaans