From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24350 invoked by alias); 26 Nov 2002 20:12:54 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24331 invoked from network); 26 Nov 2002 20:12:52 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 26 Nov 2002 20:12:52 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 2B85E3FE7; Tue, 26 Nov 2002 15:12:46 -0500 (EST) Message-ID: <3DE3D5BD.4070207@redhat.com> Date: Tue, 26 Nov 2002 12:12:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Sandiford Cc: gdb-patches@sources.redhat.com Subject: Re: Simulation of MIPS recip and rsqrt instructions References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-11/txt/msg00660.txt.bz2 > 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 > > 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