Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@redhat.com>
To: Richard Sandiford <rsandifo@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Simulation of MIPS recip and rsqrt instructions
Date: Tue, 26 Nov 2002 12:12:00 -0000	[thread overview]
Message-ID: <3DE3D5BD.4070207@redhat.com> (raw)
In-Reply-To: <m3smxom7q9.fsf@localhost.localdomain>

> The mips simulator uses sim_fpu_inv() as a reciprocal function
> but all it really does is negate the exponent.  So we end up
> calculating 1 / (x*2^y) as x*2^-y.
> 
> Test case:
> 
>     #include <stdio.h>
> 
>     int
>     main ()
>     {
>       double d;
>       float f;
> 
>       asm ("recip.s %0,%1" : "=f" (f) : "f" (20.0f));
>       printf ("%g\n", f);
> 
>       asm ("recip.d %0,%1" : "=f" (d) : "f" (10.0));
>       printf ("%g\n", d);
> 
>       asm ("rsqrt.s %0,%1" : "=f" (f) : "f" (0.01f));
>       printf ("%g\n", f);
> 
>       asm ("rsqrt.d %0,%1" : "=f" (d) : "f" (25.0));
>       printf ("%g\n", d);
> 
>       return 0;
>     }

Can this test case be written in strict assembler so that it can be 
added to the simulator testsuite?

> The simulator says:
> 
>     0.078125
>     0.15625
>     25.6
>     0.3125
> 
> while a vr5500 says:
> 
>     0.05
>     0.1
>     10
>     0.2
> 
> Unfortunately, sim_fpu_inv isn't commented and cp1.c seems to be
> its only active user.  Which should change?
> 
> FWIW, the patch below fixes the test case.  Please install if OK.

Hmm, I guess:

	1 / (x * 2^y) == (1/x) * (1/(2^y)) == (1/x) * (2^(-y))

and
	1/x != x

so I think the inv() function should be fixed - that suggests it is 
pretty broken.

Does GLIBC's softfloat code contain an efficient INV implementation that 
could be used?

Andrew



  reply	other threads:[~2002-11-26 20:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-26 11:41 Richard Sandiford
2002-11-26 12:12 ` Andrew Cagney [this message]
2002-11-26 12:38   ` Richard Sandiford
     [not found] ` <mailpost.1038339722.6479@news-sj1-1>
2002-11-26 12:42   ` cgd
2002-11-27  0:12     ` Richard Sandiford
     [not found]       ` <mailpost.1038384740.26359@news-sj1-1>
2002-11-27 17:33         ` cgd

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=3DE3D5BD.4070207@redhat.com \
    --to=ac131313@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=rsandifo@redhat.com \
    /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