From patchwork Fri Feb 19 20:55:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 585417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8123414076E for ; Sat, 20 Feb 2016 07:55:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kVmX9dmN; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=p4+yt192FPNc8EPvz HueqixCLmRiP5K+plqIFMRnbhAqgiSqyisZg7A/CnHr38cJdHLogKIpPAAl2lheG EvsGj4MdEiUlEEi2saiijGT8u9Rwkxx2PUmPyquxJBUd1csbzMELIN4gfsaZKAc5 0Q5JxuV8DycLAVmVBtii0HFlyo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=0x5KcpFzlyZE/tBGLpGbNUT 3jxg=; b=kVmX9dmNUuZsDewj6oPWSpHF91O6tqvCNZ0qN44IoV00WmtBSqAK/Hg BlbHxQn8JN3YlPDxJWBUwBwXp72Mv9hUj+BBRg9nKBHkn7HfK5yNSFeCv1yL3pcY XRU2tGJdfD9ue/DCE8s2H/iASu+yPHw3Q0KGP1s3n8Jr1cj3lfDo= Received: (qmail 108280 invoked by alias); 19 Feb 2016 20:55:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 108261 invoked by uid 89); 19 Feb 2016 20:55:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=__asm__, labels, 1309, mystery X-HELO: e17.ny.us.ibm.com Received: from e17.ny.us.ibm.com (HELO e17.ny.us.ibm.com) (129.33.205.207) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 19 Feb 2016 20:55:22 +0000 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Feb 2016 15:55:20 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Feb 2016 15:55:18 -0500 X-IBM-Helo: d01dlp02.pok.ibm.com X-IBM-MailFrom: murphyp@linux.vnet.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 8041F6E804A for ; Fri, 19 Feb 2016 15:42:09 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1JKtHTa17170508 for ; Fri, 19 Feb 2016 20:55:17 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1JKtHnv028323 for ; Fri, 19 Feb 2016 15:55:17 -0500 Received: from [9.80.90.84] ([9.80.90.84]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u1JKtEG5027940; Fri, 19 Feb 2016 15:55:14 -0500 Subject: Re: PPC libgcc IEEE128 soft-fp exception/rounding fixes To: gcc-patches@gcc.gnu.org References: <56C504D1.7050908@linux.vnet.ibm.com> <20160218023718.GI31757@bubble.grove.modra.org> Cc: Alan Modra , meissner@linux.vnet.ibm.com, Joseph Myers , wschmidt@linux.vnet.ibm.com, "munroesj@linux.vnet.ibm.com" From: "Paul E. Murphy" Message-ID: <56C78132.7070706@linux.vnet.ibm.com> Date: Fri, 19 Feb 2016 14:55:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160218023718.GI31757@bubble.grove.modra.org> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16021920-0041-0000-0000-000003564B58 On 02/17/2016 08:37 PM, Alan Modra wrote: >> +/* A set bit indicates an exception is trapping. */ >> +# define FP_TRAPPING_EXCEPTIONS ((_fpscr.i << 22) & FP_EX_ALL) > > why then a shift here, since FP_EX_* are defined as the actual > register bits? Oh, I see. FP_EX_* are the status bits, and you want > the enable bits. ie. bit 56 rather than bit 34, bit 57 rather than > bit 35 and so on (bits numbered from 0 as msb). A comment to that > effect might reduce head scratching. Thanks for taking a look Alan, and Joseph. I've expanded the comment to clarify the otherwise mysterious shift with the updated patch. libgcc * config/rs6000/sfp-machine.h: (_FP_DECL_EX): Declare _fpsr as a union of u64 and double. (FP_TRAPPING_EXCEPTIONS): Return a bitmask of trapping exceptions. (FP_INIT_ROUNDMODE): Read the fpscr instead of writing a mystery value. (FP_ROUNDMODE): Update the usage of _fpscr. diff --git a/libgcc/config/rs6000/sfp-machine.h b/libgcc/config/rs6000/sfp-machine.h index 75d5e1a..8dd8ea3 100644 --- a/libgcc/config/rs6000/sfp-machine.h +++ b/libgcc/config/rs6000/sfp-machine.h @@ -130,9 +130,13 @@ void __sfp_handle_exceptions (int); if (__builtin_expect (_fex, 0)) \ __sfp_handle_exceptions (_fex); \ } while (0); -/* A set bit indicates an exception is masked and a clear bit indicates it is - trapping. */ -# define FP_TRAPPING_EXCEPTIONS (~_fpscr & (FP_EX_ALL >> 22)) + +/* The FP_EX_* bits track whether the exception has occurred. This macro + must set the FP_EX_* bits of those exceptions which are configured to + trap. The FPSCR bit which indicates this is 22 ISA bits above the + respective FP_EX_* bit. Note, the ISA labels bits from msb to lsb, + so 22 ISA bits above is 22 bits below when counted from the lsb. */ +# define FP_TRAPPING_EXCEPTIONS ((_fpscr.i << 22) & FP_EX_ALL) # define FP_RND_NEAREST 0x0 # define FP_RND_ZERO 0x1 @@ -141,16 +145,16 @@ void __sfp_handle_exceptions (int); # define FP_RND_MASK 0x3 # define _FP_DECL_EX \ - unsigned long long _fpscr __attribute__ ((unused)) = FP_RND_NEAREST + union { unsigned long long i; double d; } _fpscr __attribute__ ((unused)) = \ + { .i = FP_RND_NEAREST } #define FP_INIT_ROUNDMODE \ do { \ - __asm__ __volatile__ ("mtfsf 255, %0" \ - : \ - : "f" (_fpscr)); \ + __asm__ __volatile__ ("mffs %0" \ + : "=f" (_fpscr.d)); \ } while (0) -# define FP_ROUNDMODE (_fpscr & FP_RND_MASK) +# define FP_ROUNDMODE (_fpscr.i & FP_RND_MASK) #endif /* !__FLOAT128__ */ /* Define ALIASNAME as a strong alias for NAME. */