State of m68k float emulation in lb1sf68.asm (muldf, divdf)

Pavel Pisa pisa@cmp.felk.cvut.cz
Mon Nov 17 23:00:00 GMT 2003


On Friday 14 November 2003 20:46, tm_gccmail@kloo.net wrote:
> On Fri, 14 Nov 2003 tm_gccmail@kloo.net wrote:
> > On Fri, 14 Nov 2003, Pavel Pisa wrote:
> > > The core part of muldf implementation can be rewritten to use
> > > something like (not fully evaluated) u64*u64->u128, this can be
> > > realized by four u32*u32->u64.
> >
> > I believe you only need three.
> >
> > The result of the fourth multiply will be shifted left 64, which means
> > it will not be used.
> >
> > Toshi
>
> Oh wait, never mind. I thought you meant u64*u64->u64.
>
> I don't think you need u64*u64->u128 anyway. IEEE754 DFmode only has 54
> bits of fraction, so the extra precision is wasted.
>
> Toshi

As I have mentioned about u64*u64->u128 computation it needs "not to be fully
evaluated". But it requires think much more, what parts can be omitted,
because there is required exact rounding by IEEE arithmetics and sums of bits
after 54-th bit can contribute to the significant portion of the result.
Computation in the u32 quantities (x=32) looks like 

a0a1 * b0b1 -> c0c1c2c3

c0c1c2c3 = ((a0*b0)<<2x) + ((a0*b1)<<x) + ((a1*b0)<<x) + (a1*b1)
             d0d1            e0e1           f0f1          g0g1

+d0d1
+  e0e1
+  f0f1
+    g0g1
----------
=c0c1c2c3

and you want 54 most significant bits from the result (all bits of c0
and some bits of c1). The situation could be even more complicated,
if preparation of the operands does not shift both input operands
to the top of the u64 variables a0a1 and b0b1. It could be good
to shift only one operand, then result of the multiplication is better
positioned in the result value and only one bit shift is required for
normalization into IEEE format.

As you can see for simple case, g1 cannot contribute to c0c1 result bits,
but sum of e1+f1+g0 can influence c1 for some values of the sum d1+e0+f0.

Best wishes

                Pavel Pisa
        e-mail: pisa@cmp.felk.cvut.cz
        www:    http://cmp.felk.cvut.cz/~pisa
        work:   http://www.pikron.com



More information about the Gcc mailing list