qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] How to add my implementation of the fmadds instruction


From: Peter Maydell
Subject: Re: [Qemu-devel] How to add my implementation of the fmadds instruction to QEMU
Date: Tue, 27 Sep 2016 08:21:08 -0700

On 27 September 2016 at 07:33, G 3 <address@hidden> wrote:
>
> On Sep 27, 2016, at 7:43 AM, Peter Maydell wrote:
>> In particular, for fmadds, it is important that there
>> is no intermediate rounding done between the multiply
>> and the addition. This means that you need to effectively
>> do the multiply and the addition at a higher precision than
>> the input arguments, so simple multiplication and addition
>> of floats will give you wrong answers.
>
>
> It sounds like I should change my argument types to double.

That will fix only a very tiny part of the problem.
You will also need to get right floating point exception flags,
handling of subnormal numbers, and various other implementation
specifics of IEEE.

> I still want to try implementing this function. I'm thinking
> rewriting the helper_fmadd() function in target-ppc/fpu_helper.c.
> Does that sound correct?

That's the place that would need to be reimplemented.
I recommend doing very thorough testing by feeding the
instruction a lot of randomly selected input values and
comparing the output value and the output floating point
status/exception flags against the current implementation
and/or real hardware.

I really think you'll find that this is just impossible
to implement correctly with the host compiler's floating
point C expressions, though.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]