From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5045 invoked by alias); 26 Nov 2002 20:38:56 -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 5037 invoked from network); 26 Nov 2002 20:38:54 -0000 Received: from unknown (HELO executor.cambridge.redhat.com) (195.224.55.237) by sources.redhat.com with SMTP; 26 Nov 2002 20:38:54 -0000 Received: from talisman.cambridge.redhat.com (talisman.cambridge.redhat.com [172.16.18.81]) by executor.cambridge.redhat.com (Postfix) with ESMTP id 7CEDFABAF8; Tue, 26 Nov 2002 20:38:53 +0000 (GMT) Received: (from rsandifo@localhost) by talisman.cambridge.redhat.com (8.11.6/8.11.0) id gAQKcrn19223; Tue, 26 Nov 2002 20:38:53 GMT X-Authentication-Warning: talisman.cambridge.redhat.com: rsandifo set sender to rsandifo@redhat.com using -f To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: Simulation of MIPS recip and rsqrt instructions References: <3DE3D5BD.4070207@redhat.com> From: Richard Sandiford Date: Tue, 26 Nov 2002 12:38:00 -0000 In-Reply-To: <3DE3D5BD.4070207@redhat.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-11/txt/msg00661.txt.bz2 Andrew Cagney writes: > Can this test case be written in strict assembler so that it can be > added to the simulator testsuite? Is there a testsuite for mips? > > Unfortunately, sim_fpu_inv isn't commented and cp1.c seems to be > > its only active user. Which should change? > > 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. OK, so sim_fpu_inv() _is_ supposed to be a general reciprocal function? Not just for powers of two, etc.? It seemed so deliberate, it was difficult to tell. Like you say, there's probably some code that could be nicked from elsewhere, but reusing sim_fpu_div should work too, even if it isn't as efficient. The patch below also fixes the test case. Richard Index: sim/common/sim-fpu.c =================================================================== RCS file: /cvs/src/src/sim/common/sim-fpu.c,v retrieving revision 1.4 diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.4 sim-fpu.c *** sim/common/sim-fpu.c 12 Jun 2002 00:46:11 -0000 1.4 --- sim/common/sim-fpu.c 26 Nov 2002 20:33:46 -0000 *************** INLINE_SIM_FPU (int) *** 1754,1786 **** sim_fpu_inv (sim_fpu *f, const sim_fpu *r) { ! if (sim_fpu_is_snan (r)) ! { ! *f = *r; ! f->class = sim_fpu_class_qnan; ! return sim_fpu_status_invalid_snan; ! } ! if (sim_fpu_is_qnan (r)) ! { ! *f = *r; ! f->class = sim_fpu_class_qnan; ! return 0; ! } ! if (sim_fpu_is_infinity (r)) ! { ! *f = sim_fpu_zero; ! f->sign = r->sign; ! return 0; ! } ! if (sim_fpu_is_zero (r)) ! { ! f->class = sim_fpu_class_infinity; ! f->sign = r->sign; ! return sim_fpu_status_invalid_div0; ! } ! *f = *r; ! f->normal_exp = - r->normal_exp; ! return 0; } --- 1754,1760 ---- sim_fpu_inv (sim_fpu *f, const sim_fpu *r) { ! return sim_fpu_div (f, &sim_fpu_one, r); }