From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28977 invoked by alias); 13 Oct 2014 23:39:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 28968 invoked by uid 89); 13 Oct 2014 23:39:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailout10.t-online.de Received: from mailout10.t-online.de (HELO mailout10.t-online.de) (194.25.134.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 13 Oct 2014 23:39:38 +0000 Received: from fwd03.aul.t-online.de (fwd03.aul.t-online.de [172.20.27.148]) by mailout10.t-online.de (Postfix) with SMTP id 481E74B2EC; Tue, 14 Oct 2014 01:39:35 +0200 (CEST) Received: from [192.168.0.103] (Vs-fMyZU8hCd2ayavGhW3ojZt4IVHHO6HFCKDnE7papPjhuknm4fBGjNbZKfv3fQz+@[84.183.238.31]) by fwd03.t-online.de with (TLSv1:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1XdpD5-1t6MIi0; Tue, 14 Oct 2014 01:39:27 +0200 Message-ID: <1413243560.31394.48.camel@yam-132-YW-E178-FTW> Subject: [SH] Correct fabs and fneg insns in simulator From: Oleg Endo To: gdb-patches@sourceware.org Cc: Kaz Kojima Date: Mon, 13 Oct 2014 23:39:00 -0000 Content-Type: multipart/mixed; boundary="=-ySRYRULypjxp6ReIWL8L" Mime-Version: 1.0 X-SW-Source: 2014-10/txt/msg00334.txt.bz2 --=-ySRYRULypjxp6ReIWL8L Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 915 Hi, It seems that the implementation of the SH fabs and fneg insns in the simulator is not correct. They use the FP_UNARY macro which checks the FPSCR.PR setting and raises an exception if PR = 1 (double precision) and the register number is not even (i.e. a valid DF reg number). For normal unary FP insns this is fine. However, fneg and fabs perform the same (integer) operations regardless of the FPSCR.PR setting. This issue initially popped up here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63260 I've checked some of the failing tests mentioned in GCC PR 63260 above with the patch applied and the failures go away. Could somebody please apply it if it's OK? I'm not subscribed to gdb-patches, please CC me when replying. Cheers, Oleg sim/ChangeLog: 2014-10-14 Oleg Endo * sh/gencode.c (fabs, fneg): Implement as integer operation instead of using the FP_UNARY macro. --=-ySRYRULypjxp6ReIWL8L Content-Disposition: attachment; filename="sh_sim_fneg_fabs.patch" Content-Type: text/x-patch; name="sh_sim_fneg_fabs.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 805 diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 738b718..bc65604 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -429,8 +429,14 @@ op tab[] = /* sh2e */ { "", "", "fabs ", "1111nnnn01011101", - "FP_UNARY (n, fabs);", - "/* FIXME: FR (n) &= 0x7fffffff; */", + " union", + " {", + " unsigned int i;", + " float f;", + " } u;", + " u.f = FR (n);", + " u.i &= 0x7fffffff;", + " SET_FR (n, u.f);", }, /* sh2e */ @@ -662,7 +668,14 @@ op tab[] = /* sh2e */ { "", "", "fneg ", "1111nnnn01001101", - "FP_UNARY (n, -);", + " union", + " {", + " unsigned int i;", + " float f;", + " } u;", + " u.f = FR (n);", + " u.i ^= 0x80000000;", + " SET_FR (n, u.f);", }, /* sh4a */ --=-ySRYRULypjxp6ReIWL8L--