Re: extended use for fast integer calculations?

From: Matt Taylor (para_at_tampabay.rr.com)
Date: 03/21/04


Date: Sun, 21 Mar 2004 07:08:03 +0000 (UTC)


"Adrian" <adrianne54@poczta.onet.pl> wrote in message
news:c3iedj$9gk$1@atlantis.news.tpi.pl...
> Hello!
> I've read extended type documentation, and there's stated that number of
> fraction bits is 64, so I've got an idea that it could be used for fast
> multiplication of two 32-bit integers, or for division of 64-bit integer.
Is
> that possible that operations in which either arguments or result is 64
bit
> are calculated on extended precisly, just as they would be calculated
using
> general-use registers? It could accelerate some operations on long
integers
> (over 1024 bits), but absolute precision is of highest importance.

Are you talking about the FPU extended precision format (80-bits; 64-bits
precision)? Yes, on current 32-bit machines that may be worthwhile in some
cases. The integer multiplier will compute the 64-bit product of 2 32-bit
integers faster than you could load it into the FP unit, but the FP unit
could be used for the 128-bit product of 2 64-bit integers. Let the FP
multiplier compute the upper half while the integer multiplier computes the
lower half (2 partial + 1 full). The code would be quite messy, but it
should be faster than doing 4 full integer multiplies. On Athlon, the full
multiply is 6 cycles. The FP multiply takes 4 cycles, and it will take some
time to load and store results. On a Pentium-IV you may as well not bother
with the integer multiply at all.

The FP unit can also be used for extended precision division. As long as the
integer result fits into 64-bits, the FP unit can do it with perfect
precision.

You can load 64-bit signed integers directly, but you can't load unsigned
integers. You have to store them in the 80-bit format and load that.

-Matt


Loading