From: Richard Henderson <richard.henderson@linaro.org>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, thuth@redhat.com, philmd@redhat.com,
yangxiaojuan@loongson.cn, laurent@vivier.eu, peterx@redhat.com,
alistair.francis@wdc.com, maobibo@loongson.cn,
pbonzini@redhat.com, bmeng.cn@gmail.com, alex.bennee@linaro.org,
chenhuacai@loongson.cn
Subject: Re: [PATCH v5 10/21] target/loongarch: Add floating point arithmetic instruction translation
Date: Tue, 14 Sep 2021 07:15:41 -0700 [thread overview]
Message-ID: <f9c65cce-5235-d8cd-ee2e-0a47d51548d8@linaro.org> (raw)
In-Reply-To: <1631624431-30658-11-git-send-email-gaosong@loongson.cn>
On 9/14/21 6:00 AM, Song Gao wrote:
> +static void update_fcsr0_mask(CPULoongArchState *env, uintptr_t pc, int mask)
> +{
> + int flags = get_float_exception_flags(&env->fp_status) & (~mask);
> +
> + if (!flags) {
> + SET_FP_CAUSE(env->fcsr0, flags);
> + return;
If mask != 0, we may unintentionally leave fp_status.flags != 0, which will then be
incorporated into the next fp operation.
> + }
> +
> + flags = ieee_ex_to_loongarch(flags);
> + set_float_exception_flags(0, &env->fp_status);
I think this set should move above the if.
> +static bool trans_fmax_s(DisasContext *ctx, arg_fmt_fdfjfk *a)
> +{
> + tcg_gen_umax_i64(cpu_fpr[a->fd], cpu_fpr[a->fj], cpu_fpr[a->fk]);
Um, this is an integer operation. You want float32_maxnum.
Likewise for the other min/max operations.
> +static bool trans_fabs_s(DisasContext *ctx, arg_fmt_fdfj *a)
> +{
> + tcg_gen_ext32u_tl(cpu_fpr[a->fj], cpu_fpr[a->fj]);
You shouldn't be modifying fj.
> + tcg_gen_abs_i64(cpu_fpr[a->fd], cpu_fpr[a->fj]);
This is an integer operation. You want
tcg_gen_andi_i64(cpu_fpr[a->fd], cpu_fpr[a->fj],
MAKE_64BIT_MASK(0, 31));
> +static bool trans_fabs_d(DisasContext *ctx, arg_fmt_fdfj *a)
> +{
> + tcg_gen_abs_i64(cpu_fpr[a->fd], cpu_fpr[a->fj]);
Similarly.
> +/*
> + * LoongArch requires NaN-boxing of narrower width floating point values.
> + * This applies when a 32-bit value is assigned to a 64-bit FP register.
> + */
Um, this comment does not reflect the language in the v1.00 manual.
The actual language says that the upper 32 bits are undefined ("can be any value"). We
should state that here, and then that QEMU chooses to nanbox, because it is most likely to
show guest bugs early.
r~
next prev parent reply other threads:[~2021-09-14 14:18 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 13:00 [PATCH v5 00/21] Add LoongArch linux-user emulation support Song Gao
2021-09-14 13:00 ` [PATCH v5 01/21] target/loongarch: Add README Song Gao
2021-09-14 13:00 ` [PATCH v5 02/21] target/loongarch: Add core definition Song Gao
2021-09-14 13:00 ` [PATCH v5 03/21] target/loongarch: Add main translation routines Song Gao
2021-09-14 13:00 ` [PATCH v5 04/21] target/loongarch: Add fixed point arithmetic instruction translation Song Gao
2021-09-14 13:30 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 05/21] target/loongarch: Add fixed point shift " Song Gao
2021-09-14 13:33 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 06/21] target/loongarch: Add fixed point bit " Song Gao
2021-09-14 13:45 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 07/21] target/loongarch: Add fixed point load/store " Song Gao
2021-09-14 13:47 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 08/21] target/loongarch: Add fixed point atomic " Song Gao
2021-09-14 13:49 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 09/21] target/loongarch: Add fixed point extra " Song Gao
2021-09-14 13:00 ` [PATCH v5 10/21] target/loongarch: Add floating point arithmetic " Song Gao
2021-09-14 14:15 ` Richard Henderson [this message]
2021-09-14 13:00 ` [PATCH v5 11/21] target/loongarch: Add floating point comparison " Song Gao
2021-09-14 14:21 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 12/21] target/loongarch: Add floating point conversion " Song Gao
2021-09-14 13:00 ` [PATCH v5 13/21] target/loongarch: Add floating point move " Song Gao
2021-09-14 14:24 ` Richard Henderson
2021-09-14 13:00 ` [PATCH v5 14/21] target/loongarch: Add floating point load/store " Song Gao
2021-09-14 13:00 ` [PATCH v5 15/21] target/loongarch: Add branch " Song Gao
2021-09-14 13:00 ` [PATCH v5 16/21] target/loongarch: Add disassembler Song Gao
2021-09-14 13:00 ` [PATCH v5 17/21] LoongArch Linux User Emulation Song Gao
2021-09-14 13:00 ` [PATCH v5 18/21] default-configs: Add loongarch linux-user support Song Gao
2021-09-14 13:00 ` [PATCH v5 19/21] target/loongarch: Add target build suport Song Gao
2021-09-14 13:00 ` [PATCH v5 20/21] target/loongarch: 'make check-tcg' support Song Gao
2021-09-14 13:00 ` [PATCH v5 21/21] scripts: add loongarch64 binfmt config Song Gao
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=f9c65cce-5235-d8cd-ee2e-0a47d51548d8@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=chenhuacai@loongson.cn \
--cc=gaosong@loongson.cn \
--cc=laurent@vivier.eu \
--cc=maobibo@loongson.cn \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=yangxiaojuan@loongson.cn \
/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).