lkml.org 
[lkml]   [2000]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
DateFri, 04 Aug 2000 18:08:38 -0600
From"Jeff V. Merkey" <>
SubjectRe: 64 bit divide/mod in 2.4.0-test5

Linus.

a = val >> shift

for 64 bits divides and

a = val >> shift;
b = val - (a << shift)

for 64 bit modulo operations

seem to be the cleanest and lowest overhead way for this and these were
provided by folks on the list in response to this thread. I have
already incorporated them and the code builds fine. I have not
disassembled it to see how many instructions this is taking but I only
do 64-bit math infrequently, so it should be minimal.

(Thanks everyone who helped out here).

:-)

Jeff

Linus Torvalds wrote:
>
> In article <d3n1itxely.fsf@lxplus015.cern.ch>,
> Jes Sorensen <jes@linuxcare.com> wrote:
> >
> >Well you are seeing those because it's deprecated, you should use a
> >shift operator instead if in any way possible.
>
> Indeed. Basically, I _know_ that I could include libgcc, but I also do
> not believe that people should get code that looks simple but takes
> hundreds of cycles to complete.
>
> The fact that 64-bit divisions do not work naturally has actually saved
> us a number of times from people just not thinking about what an
> expensive operation such a division is - quite often there is a trivial
> shift that can do the same thing in two cycles or similar.
>
> There's some special-case code in <asm/div64.h>, which is used mainly
> for printk(), but can be used for other stuff too: a 64-by-64 divide is
> usually much slower than a 64-by-32 divide which is actually the one
> that most people are looking for anyway (but gcc isn't clever enough to
> know this). That can be used if you _really_ think you need the divide.
> I've yet to see a real reason for it outside the printk() stuff..
>
> Linus
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2010