On 27 September 2016 at 07:33, G 3 <programmingk...@gmail.com> 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