From: Richard Henderson <richard.henderson@linaro.org>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
laurent@vivier.eu, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 4/4] target/m68k: fix FPSR quotient byte for frem instruction
Date: Wed, 4 Jan 2023 10:04:47 -0800 [thread overview]
Message-ID: <51da8243-885d-a98e-deb6-746383da1d7d@linaro.org> (raw)
In-Reply-To: <20230104134554.138012-5-mark.cave-ayland@ilande.co.uk>
On 1/4/23 05:45, Mark Cave-Ayland wrote:
> The FPSR quotient byte should be set to the value of the quotient and not the
> result. Manually calculate the quotient in the frem helper in round to nearest
> even mode (note this is different from the quotient calculated internally for
> fmod), and use it to set the quotient byte accordingly.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1314
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
> target/m68k/fpu_helper.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
> index 5fd094a33c..56f7400140 100644
> --- a/target/m68k/fpu_helper.c
> +++ b/target/m68k/fpu_helper.c
> @@ -538,17 +538,25 @@ void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
>
> void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
> {
> + float_status fp_status;
> + FPReg fp_quot;
> uint32_t quotient;
> int sign;
>
> + /* Calculate quotient directly using round to nearest mode */
> + set_float_rounding_mode(float_round_nearest_even, &fp_status);
> + set_floatx80_rounding_precision(
> + get_floatx80_rounding_precision(&env->fp_status), &fp_status);
> + fp_quot.d = floatx80_div(val1->d, val0->d, &fp_status);
> +
> res->d = floatx80_rem(val1->d, val0->d, &env->fp_status);
>
> - if (floatx80_is_any_nan(res->d)) {
> + if (floatx80_is_any_nan(fp_quot.d)) {
I think you should leave this line unchanged, and move the div afterward.
I also think you should completely initialize the local fp_status = { }.
With that,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2023-01-04 18:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 13:45 [PATCH v2 0/4] target/m68k: fix FPSR quotient byte for fmod and frem Mark Cave-Ayland
2023-01-04 13:45 ` [PATCH v2 1/4] target/m68k: pass quotient directly into make_quotient() Mark Cave-Ayland
2023-01-04 17:37 ` Richard Henderson
2023-01-04 13:45 ` [PATCH v2 2/4] target/m68k: pass sign " Mark Cave-Ayland
2023-01-04 16:04 ` Laurent Vivier
2023-01-04 17:38 ` Richard Henderson
2023-01-04 13:45 ` [PATCH v2 3/4] target/m68k: fix FPSR quotient byte for fmod instruction Mark Cave-Ayland
2023-01-04 17:59 ` Richard Henderson
2023-01-04 13:45 ` [PATCH v2 4/4] target/m68k: fix FPSR quotient byte for frem instruction Mark Cave-Ayland
2023-01-04 18:04 ` Richard Henderson [this message]
2023-01-07 23:00 ` Mark Cave-Ayland
2023-01-09 1:55 ` Richard Henderson
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=51da8243-885d-a98e-deb6-746383da1d7d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=laurent@vivier.eu \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).