qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] target/ppc: rewrite f[n]m[add, sub] using fl


From: Nikunj A Dadhania
Subject: Re: [Qemu-devel] [PATCH v2] target/ppc: rewrite f[n]m[add, sub] using float64_muladd
Date: Fri, 03 Mar 2017 09:31:52 +0530
User-agent: Notmuch/0.21 (https://notmuchmail.org) Emacs/25.0.94.1 (x86_64-redhat-linux-gnu)

Richard Henderson <address@hidden> writes:
> On 03/03/2017 01:10 AM, Nikunj A Dadhania wrote:
>> +static void float64_maddsub_update_excp(CPUPPCState *env, float64 arg1,
>> +                                        float64 arg2, float64 arg3,
>> +                                        unsigned int madd_flags)
>>  {
>> +    if (unlikely((float64_is_infinity(arg1) && float64_is_zero(arg2)) ||
>> +                 (float64_is_zero(arg1) && float64_is_infinity(arg2)))) {
>>          /* Multiplication of zero by infinity */
>> +        arg1 = float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1);
>> +    } else if (unlikely(float64_is_signaling_nan(arg1, &env->fp_status) ||
>> +                        float64_is_signaling_nan(arg2, &env->fp_status) ||
>> +                        float64_is_signaling_nan(arg3, &env->fp_status))) {
>> +        /* sNaN operation */
>> +        float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
>
> Are you sure you shouldn't be testing for NaN first?

I have tried to retain the old order of checking. While when I see
MultiplyAddDP(x,y,z) in ISA, following is the order:

    * If x, y or z is an SNaN, vxsnan_flag is set to 1.
    * If x is a Zero and y, is an Infinity or x is an Infinity and y is
      an Zero, vximz_flag is set to 1.
    * If the product of x and y is an Infinity and z is an Infinity of
      the opposite sign, vxisi_flag is set to 1.

In that case, I need to get rid of nested if-else and make each of them
independent checks.
    
> Do you really get VXIMZ if arg3 (the addend) is (S)NaN?

Yes, with the above logic yes. 

> You should probably eliminate QNaN as well, before the other checks.

MultiplyAddDP does not eliminate QNaN. But then, there is detailed spec
on what should be returned in various cases(Page 469 ISA 3.0)

Regards
Nikunj




reply via email to

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