From: Aurelien Jarno <aurelien@aurel32.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] target-arm: Fix VMLA, VMLS, VNMLS, VNMLA handling of NaNs
Date: Sun, 15 May 2011 00:23:45 +0200 [thread overview]
Message-ID: <20110514222344.GD13600@volta.aurel32.net> (raw)
In-Reply-To: <1304620535-28885-1-git-send-email-peter.maydell@linaro.org>
On Thu, May 05, 2011 at 07:35:35PM +0100, Peter Maydell wrote:
> Correct handling of NaNs for VFP VMLA, VMLS, VNMLS and VNMLA requires that
> we implement the set of negations and additions specified by the ARM ARM;
> plausible looking simplifications like turning (-A + B) into (B - A) or
> computing (A + B) rather than (B + A) result in selecting the wrong NaN or
> returning a NaN with the wrong sign bit.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target-arm/translate.c | 53 ++++++++++++++++++++++++++++++++++++-----------
> 1 files changed, 40 insertions(+), 13 deletions(-)
Thanks, applied.
> diff --git a/target-arm/translate.c b/target-arm/translate.c
> index a1af436..3c38364 100644
> --- a/target-arm/translate.c
> +++ b/target-arm/translate.c
> @@ -909,6 +909,26 @@ VFP_OP2(div)
>
> #undef VFP_OP2
>
> +static inline void gen_vfp_F1_mul(int dp)
> +{
> + /* Like gen_vfp_mul() but put result in F1 */
> + if (dp) {
> + gen_helper_vfp_muld(cpu_F1d, cpu_F0d, cpu_F1d, cpu_env);
> + } else {
> + gen_helper_vfp_muls(cpu_F1s, cpu_F0s, cpu_F1s, cpu_env);
> + }
> +}
> +
> +static inline void gen_vfp_F1_neg(int dp)
> +{
> + /* Like gen_vfp_neg() but put result in F1 */
> + if (dp) {
> + gen_helper_vfp_negd(cpu_F1d, cpu_F0d);
> + } else {
> + gen_helper_vfp_negs(cpu_F1s, cpu_F0s);
> + }
> +}
> +
> static inline void gen_vfp_abs(int dp)
> {
> if (dp)
> @@ -3021,27 +3041,34 @@ static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
> for (;;) {
> /* Perform the calculation. */
> switch (op) {
> - case 0: /* mac: fd + (fn * fm) */
> - gen_vfp_mul(dp);
> - gen_mov_F1_vreg(dp, rd);
> + case 0: /* VMLA: fd + (fn * fm) */
> + /* Note that order of inputs to the add matters for NaNs */
> + gen_vfp_F1_mul(dp);
> + gen_mov_F0_vreg(dp, rd);
> gen_vfp_add(dp);
> break;
> - case 1: /* nmac: fd - (fn * fm) */
> + case 1: /* VMLS: fd + -(fn * fm) */
> gen_vfp_mul(dp);
> - gen_vfp_neg(dp);
> - gen_mov_F1_vreg(dp, rd);
> + gen_vfp_F1_neg(dp);
> + gen_mov_F0_vreg(dp, rd);
> gen_vfp_add(dp);
> break;
> - case 2: /* msc: -fd + (fn * fm) */
> - gen_vfp_mul(dp);
> - gen_mov_F1_vreg(dp, rd);
> - gen_vfp_sub(dp);
> + case 2: /* VNMLS: -fd + (fn * fm) */
> + /* Note that it isn't valid to replace (-A + B) with (B - A)
> + * or similar plausible looking simplifications
> + * because this will give wrong results for NaNs.
> + */
> + gen_vfp_F1_mul(dp);
> + gen_mov_F0_vreg(dp, rd);
> + gen_vfp_neg(dp);
> + gen_vfp_add(dp);
> break;
> - case 3: /* nmsc: -fd - (fn * fm) */
> + case 3: /* VNMLA: -fd + -(fn * fm) */
> gen_vfp_mul(dp);
> + gen_vfp_F1_neg(dp);
> + gen_mov_F0_vreg(dp, rd);
> gen_vfp_neg(dp);
> - gen_mov_F1_vreg(dp, rd);
> - gen_vfp_sub(dp);
> + gen_vfp_add(dp);
> break;
> case 4: /* mul: fn * fm */
> gen_vfp_mul(dp);
> --
> 1.7.1
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
prev parent reply other threads:[~2011-05-14 22:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 18:35 [Qemu-devel] [PATCH] target-arm: Fix VMLA, VMLS, VNMLS, VNMLA handling of NaNs Peter Maydell
2011-05-14 22:23 ` Aurelien Jarno [this message]
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=20110514222344.GD13600@volta.aurel32.net \
--to=aurelien@aurel32.net \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--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).