qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Froyd <froydnj@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target-ppc: fix fcmp{o,u} instructions
Date: Sun, 14 Dec 2008 04:51:14 -0800	[thread overview]
Message-ID: <20081214125114.GH23471@codesourcery.com> (raw)
In-Reply-To: <20081214103554.GG17729@volta.aurel32.net>

On Sun, Dec 14, 2008 at 11:35:54AM +0100, Aurelien Jarno wrote:
> > -uint32_t helper_fcmpu (uint64_t arg1, uint64_t arg2)
> > +void helper_fcmpu (uint64_t arg1, uint64_t arg2, uint32_t crfD)
> >  {
> >      CPU_DoubleU farg1, farg2;
> >      uint32_t ret = 0;
> >      farg1.ll = arg1;
> >      farg2.ll = arg2;
> >  
> > -    if (unlikely(float64_is_signaling_nan(farg1.d) ||
> > -                 float64_is_signaling_nan(farg2.d))) {
> > -        /* sNaN comparison */
> > -        fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
> > +    if (unlikely(float64_is_nan(farg1.d) ||
> > +                 float64_is_nan(farg2.d))) {
> > +        ret = 0x01UL;
> > +    } else if (float64_lt(farg1.d, farg2.d, &env->fp_status)) {
> > +        ret = 0x08UL;
> > +    } else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) {
> > +        ret = 0x04UL;
> >      } else {
> > -        if (float64_lt(farg1.d, farg2.d, &env->fp_status)) {
> > -            ret = 0x08UL;
> > -        } else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) {
> > -            ret = 0x04UL;
> > -        } else {
> > -            ret = 0x02UL;
> > -        }
> > +        ret = 0x02UL;
> >      }
> > +
> >      env->fpscr &= ~(0x0F << FPSCR_FPRF);
> >      env->fpscr |= ret << FPSCR_FPRF;
> > -    return ret;
> > +    env->crf[crfD] = ret;
> > +    if (unlikely(ret == 0x01UL
> 
> Why do you need to test if the result is 0x01UL?
> 
> > +                 && (float64_is_signaling_nan(farg1.d) ||
> > +                     float64_is_signaling_nan(farg2.d)))) {
> 
> If at least one of the arguments is a sNaN, the result should already by
> 0x01.

My reasoning was that testing for NaNness would be relatively expensive
and that NaN input should be infrequent.  Testing for 0x01UL would
therefore be a quick check to see if we need to do more expensive
checks.  I'm happy to redo the patch in the interest of clarity.

> > +    if (unlikely (ret == 0x01UL)) {
> >          if (float64_is_signaling_nan(farg1.d) ||
> >              float64_is_signaling_nan(farg2.d)) {
> >              /* sNaN comparison */
> 
> Same here.

Ditto.

-Nathan

  reply	other threads:[~2008-12-14 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-14  2:56 [Qemu-devel] [PATCH] target-ppc: fix fcmp{o,u} instructions Nathan Froyd
2008-12-14 10:35 ` Aurelien Jarno
2008-12-14 12:51   ` Nathan Froyd [this message]
2008-12-14 19:10   ` Nathan Froyd
2008-12-14 19:34     ` Aurelien Jarno

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=20081214125114.GH23471@codesourcery.com \
    --to=froydnj@codesourcery.com \
    --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).