From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17023 invoked by alias); 8 Jul 2005 05:19:15 -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 17000 invoked by uid 22791); 8 Jul 2005 05:19:02 -0000 Received: from yosemite.airs.com (HELO yosemite.airs.com) (205.217.158.180) by sourceware.org (qpsmtpd/0.30-dev) with SMTP; Fri, 08 Jul 2005 05:19:02 +0000 Received: (qmail 8413 invoked by uid 10); 8 Jul 2005 05:19:00 -0000 Received: (qmail 8858 invoked by uid 500); 8 Jul 2005 05:18:53 -0000 To: gdb-patches@sourceware.org Subject: PATCH RFA: Fix simulator handling of floating point absolute value From: Ian Lance Taylor Date: Fri, 08 Jul 2005 05:19:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2005-07/txt/msg00077.txt.bz2 The common simulator routine sim_fpu_abs is used by MIPS, MN10300, SH64, and perhaps some CGEN generated simulators (it is called by cgen-accfp.c). On most, and perhaps all, hardware, a floating point absolute value instruction simply clears the sign bit. However, sim_fpu_abs does not clear the sign bit when given a NaN. For MIPS, this causes the gcc test gcc.c-torture/execute/ieee/copysign1.c to fail. This patch changes sim_fpu_abs to always clear the sign bit of the argument. It does not otherwise change the behaviour. This, plus another patch I am about to sign, fixes the gcc copysign1 test for MIPS. OK for mainline? Ian 2005-07-07 Ian Lance Taylor * sim-fpu.c (sim_fpu_abs): Always clear the sign bit. Index: common/sim-fpu.c =================================================================== RCS file: /cvs/src/src/sim/common/sim-fpu.c,v retrieving revision 1.8 diff -p -u -r1.8 sim-fpu.c --- common/sim-fpu.c 22 Jun 2003 13:36:26 -0000 1.8 +++ common/sim-fpu.c 8 Jul 2005 05:05:12 -0000 @@ -1733,19 +1744,13 @@ INLINE_SIM_FPU (int) sim_fpu_abs (sim_fpu *f, const sim_fpu *r) { + *f = *r; + f->sign = 0; 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; - return 0; - } - *f = *r; - f->sign = 0; return 0; }