All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
	qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, ehabkost@redhat.com,
	kbastian@mail.uni-paderborn.de, mark.cave-ayland@ilande.co.uk,
	agraf@suse.de, petar.jovanovic@imgtec.com, blauwirbel@gmail.com,
	jcmvbkbc@gmail.com, miodrag.dinic@imgtec.com,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org, pbonzini@redhat.com,
	gxt@mprc.pku.edu.cn, leon.alrae@imgtec.com, afaerber@suse.de,
	aurelien@aurel32.net, proljc@gmail.com
Subject: Re: [Qemu-arm] [PATCH 2/2] target-mips: Implement IEEE 754-2008 functionality for R6 and MSA instructions
Date: Mon, 28 Mar 2016 14:49:41 -0700	[thread overview]
Message-ID: <56F9A6F5.2050504@twiddle.net> (raw)
In-Reply-To: <1458910214-12239-3-git-send-email-aleksandar.markovic@rt-rk.com>

On 03/25/2016 05:50 AM, Aleksandar Markovic wrote:
> @@ -2621,9 +2621,23 @@ uint64_t helper_float_cvtl_d(CPUMIPSState *env, uint64_t fdt0)
>       uint64_t dt2;
>
>       dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
> -    if (get_float_exception_flags(&env->active_fpu.fp_status)
> -        & (float_flag_invalid | float_flag_overflow)) {
> -        dt2 = FP_TO_INT64_OVERFLOW;
> +    if (env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) {
> +        if (get_float_exception_flags(&env->active_fpu.fp_status)
> +                & (float_flag_invalid | float_flag_overflow)) {
> +            if (float64_is_any_nan(fdt0)) {
> +                dt2 = 0;
> +            } else {
> +                if (float64_is_neg(fdt0))
> +                    dt2 = INT64_MIN;
> +                else
> +                    dt2 = INT64_MAX;
> +            }
> +        }
> +    } else {
> +        if (get_float_exception_flags(&env->active_fpu.fp_status)
> +                & (float_flag_invalid | float_flag_overflow)) {
> +            dt2 = FP_TO_INT64_OVERFLOW;
> +        }

Better to swap the tests here, so that you test the exception flags first (and 
once).  That is the exceptional condition, the one that will be true least 
often.  After that, FCR31_NAN2008 will be tested only when needed.

But also, this pattern is replicated so many times you'd do well to pull this 
sequence out to helper functions (one for s, one for d).

> +uint64_t helper_float_abs_d(CPUMIPSState *env, uint64_t fdt0)
> +{
> +    uint64_t fdt1;
> +
> +    if (env->active_fpu.fcr31 & (1 << FCR31_ABS2008)) {
> +        fdt1 = float64_abs(fdt0);
> +    } else {
> +        if (float64_is_neg(fdt0)) {
> +            fdt1 = float64_sub(0, fdt0, &env->active_fpu.fp_status);
> +        } else {
> +            fdt1 = float64_add(0, fdt0, &env->active_fpu.fp_status);
> +        }
> +        update_fcr31(env, GETPC());

Here you're better off using two separate helper functions, and chose the 
correct one during translation.  Indeed, since the 2008 version is a simple 
bit-flip, you needn't actually have a helper; just expand the sequence inline.


r~

WARNING: multiple messages have this Message-ID (diff)
From: Richard Henderson <rth@twiddle.net>
To: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
	qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, ehabkost@redhat.com,
	kbastian@mail.uni-paderborn.de, mark.cave-ayland@ilande.co.uk,
	agraf@suse.de, petar.jovanovic@imgtec.com, blauwirbel@gmail.com,
	jcmvbkbc@gmail.com, miodrag.dinic@imgtec.com,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	edgar.iglesias@gmail.com, pbonzini@redhat.com,
	gxt@mprc.pku.edu.cn, leon.alrae@imgtec.com, afaerber@suse.de,
	aurelien@aurel32.net, proljc@gmail.com
Subject: Re: [Qemu-devel] [PATCH 2/2] target-mips: Implement IEEE 754-2008 functionality for R6 and MSA instructions
Date: Mon, 28 Mar 2016 14:49:41 -0700	[thread overview]
Message-ID: <56F9A6F5.2050504@twiddle.net> (raw)
In-Reply-To: <1458910214-12239-3-git-send-email-aleksandar.markovic@rt-rk.com>

On 03/25/2016 05:50 AM, Aleksandar Markovic wrote:
> @@ -2621,9 +2621,23 @@ uint64_t helper_float_cvtl_d(CPUMIPSState *env, uint64_t fdt0)
>       uint64_t dt2;
>
>       dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
> -    if (get_float_exception_flags(&env->active_fpu.fp_status)
> -        & (float_flag_invalid | float_flag_overflow)) {
> -        dt2 = FP_TO_INT64_OVERFLOW;
> +    if (env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) {
> +        if (get_float_exception_flags(&env->active_fpu.fp_status)
> +                & (float_flag_invalid | float_flag_overflow)) {
> +            if (float64_is_any_nan(fdt0)) {
> +                dt2 = 0;
> +            } else {
> +                if (float64_is_neg(fdt0))
> +                    dt2 = INT64_MIN;
> +                else
> +                    dt2 = INT64_MAX;
> +            }
> +        }
> +    } else {
> +        if (get_float_exception_flags(&env->active_fpu.fp_status)
> +                & (float_flag_invalid | float_flag_overflow)) {
> +            dt2 = FP_TO_INT64_OVERFLOW;
> +        }

Better to swap the tests here, so that you test the exception flags first (and 
once).  That is the exceptional condition, the one that will be true least 
often.  After that, FCR31_NAN2008 will be tested only when needed.

But also, this pattern is replicated so many times you'd do well to pull this 
sequence out to helper functions (one for s, one for d).

> +uint64_t helper_float_abs_d(CPUMIPSState *env, uint64_t fdt0)
> +{
> +    uint64_t fdt1;
> +
> +    if (env->active_fpu.fcr31 & (1 << FCR31_ABS2008)) {
> +        fdt1 = float64_abs(fdt0);
> +    } else {
> +        if (float64_is_neg(fdt0)) {
> +            fdt1 = float64_sub(0, fdt0, &env->active_fpu.fp_status);
> +        } else {
> +            fdt1 = float64_add(0, fdt0, &env->active_fpu.fp_status);
> +        }
> +        update_fcr31(env, GETPC());

Here you're better off using two separate helper functions, and chose the 
correct one during translation.  Indeed, since the 2008 version is a simple 
bit-flip, you needn't actually have a helper; just expand the sequence inline.


r~

  reply	other threads:[~2016-03-28 21:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-25 12:50 [Qemu-arm] [PATCH 0/2] target-mips: Fix IEEE 754-2008-related issues Aleksandar Markovic
2016-03-25 12:50 ` [Qemu-devel] " Aleksandar Markovic
2016-03-25 12:50 ` [Qemu-arm] [PATCH 1/2] softfloat: Enable run-time-configurable meaning of signaling NaN bit Aleksandar Markovic
2016-03-25 12:50   ` [Qemu-devel] " Aleksandar Markovic
2016-03-28 21:36   ` [Qemu-arm] " Richard Henderson
2016-03-28 21:36     ` [Qemu-devel] " Richard Henderson
2016-04-04 13:21     ` [Qemu-arm] " Aleksandar Markovic
2016-04-04 13:21       ` Aleksandar Markovic
2016-04-04 13:31       ` [Qemu-arm] " Peter Maydell
2016-04-04 13:31         ` Peter Maydell
2016-04-04 19:37         ` [Qemu-arm] " Eduardo Habkost
2016-04-04 19:37           ` Eduardo Habkost
2016-04-04 19:38           ` [Qemu-arm] " Peter Maydell
2016-04-04 19:38             ` Peter Maydell
2016-04-04 19:42             ` [Qemu-arm] " Eduardo Habkost
2016-04-04 19:42               ` Eduardo Habkost
2016-04-04 19:46               ` Peter Maydell
2016-04-04 19:56                 ` [Qemu-arm] " Eduardo Habkost
2016-04-04 19:56                   ` Eduardo Habkost
2016-03-29 12:50   ` Bastian Koppelmann
2016-03-30 16:58     ` Aleksandar Markovic
2016-04-01 19:02   ` Leon Alrae
2016-04-01 19:02     ` Leon Alrae
2016-04-03 14:25     ` [Qemu-arm] " Aleksandar Markovic
2016-04-03 14:25       ` Aleksandar Markovic
2016-04-04 16:10       ` [Qemu-arm] " Leon Alrae
2016-04-04 16:10         ` Leon Alrae
2016-03-25 12:50 ` [Qemu-arm] [PATCH 2/2] target-mips: Implement IEEE 754-2008 functionality for R6 and MSA instructions Aleksandar Markovic
2016-03-25 12:50   ` [Qemu-devel] " Aleksandar Markovic
2016-03-28 21:49   ` Richard Henderson [this message]
2016-03-28 21:49     ` Richard Henderson
2016-03-30 19:28     ` [Qemu-arm] " Aleksandar Markovic
2016-03-30 19:28       ` Aleksandar Markovic
2016-03-31 11:55     ` [Qemu-arm] " Aleksandar Markovic
2016-03-31 11:55       ` Aleksandar Markovic
2016-03-31 16:30       ` [Qemu-arm] " Richard Henderson
2016-03-31 16:30         ` Richard Henderson
2016-04-01 19:07   ` Leon Alrae
2016-04-01 19:07     ` Leon Alrae
2016-04-03 15:05     ` [Qemu-arm] " Aleksandar Markovic
2016-04-03 15:05       ` [Qemu-devel] " Aleksandar Markovic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F9A6F5.2050504@twiddle.net \
    --to=rth@twiddle.net \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aleksandar.markovic@rt-rk.com \
    --cc=aurelien@aurel32.net \
    --cc=blauwirbel@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=jcmvbkbc@gmail.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=leon.alrae@imgtec.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=miodrag.dinic@imgtec.com \
    --cc=pbonzini@redhat.com \
    --cc=petar.jovanovic@imgtec.com \
    --cc=peter.maydell@linaro.org \
    --cc=proljc@gmail.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.