From patchwork Fri May 16 16:57:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 975 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id E974B360098 for ; Fri, 16 May 2014 09:59:16 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id AFE5C41BDB5E7; Fri, 16 May 2014 09:59:16 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.g.dreamhost.com 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 homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 9101241BDB5DE for ; Fri, 16 May 2014 09:59:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=pCGUtb9egbq3aCXZq9C+4xEG4phn2JJCzdbUzml9Oed VkWtomgoGFuAF/VL0oygVInABvkI4B9JNCM/YIt+nDjezk7i88RRiESoTRzRF/dj Z4wCblI+w1Xqfs9ZjCVHgtRNFXouqG3PxRQNd9DWb70opogngm2+DCjMBq9yRhgo = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version:content-type:content-transfer-encoding; s=default; bh=yDf2fgEDA55eU6hZQUUlYVHfwKk=; b=w6qQBovXAxmNbC9kg 5rSc1c0NVBcvItP6lBWt5Mtk4AD9tbpIAVTy1AxI02uQWNiMn07EofVN2GN4h6h+ V+7Sgv5DN5zYxSoLxb/Kt/7fRqWmOhMZvWFsVAt8b5NP6wP7gPfVqJ9JdDqOtIip Y8EfA67sWYFwJhEAsFNsttuSDY= Received: (qmail 26243 invoked by alias); 16 May 2014 16:58:52 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 26101 invoked by uid 89); 16 May 2014 16:58:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=unavailable version=3.3.2 X-HELO: relay1.mentorg.com Date: Fri, 16 May 2014 17:57:51 +0100 From: "Maciej W. Rozycki" To: Joey Ye , "Joseph S. Myers" CC: , Subject: Re: [PATCH] Fix ARM NAN fraction bits In-Reply-To: <000b01cf3367$439c5280$cad4f780$@arm.com> Message-ID: References: <000b01cf3367$439c5280$cad4f780$@arm.com> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in On Thu, 27 Feb 2014, Joey Ye wrote: > Current ARM soft-float implementation is violating the RTABI > (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0043d/IHI0043D_rtabi.pd > f) Section 4.1.1.1: > > When not otherwise specified by IEEE 754, the result on an invalid operation > should be the quiet NaN bit pattern with only the most significant bit of > the significand set, and all other significand bits zero. > > This patch fixes it by setting _FP_NANFRAC_* to zero. > > Ran make check test with –mfloat-abi=soft. No regression. > > OK to checkin? > > 2014-02-27  Joey Ye  > * sysdeps/arm/soft-fp/sfp-machine.h >   (_FP_NANFRAC_S, _FP_NANFRAC_D, _FP_NANFRAC_Q): >   Set to zero. > > > diff --git a/sysdeps/arm/soft-fp/sfp-machine.h > b/sysdeps/arm/soft-fp/sfp-machine.h > index 52a08b5..32697fe 100644 > --- a/sysdeps/arm/soft-fp/sfp-machine.h > +++ b/sysdeps/arm/soft-fp/sfp-machine.h > @@ -21,9 +21,9 @@ > #define _FP_DIV_MEAT_D(R,X,Y)          _FP_DIV_MEAT_2_udiv(D,R,X,Y) > #define _FP_DIV_MEAT_Q(R,X,Y)          _FP_DIV_MEAT_4_udiv(Q,R,X,Y) > > -#define _FP_NANFRAC_S                          ((_FP_QNANBIT_S << 1) - 1) > -#define _FP_NANFRAC_D                         ((_FP_QNANBIT_D << 1) - 1), > -1 > -#define _FP_NANFRAC_Q                         ((_FP_QNANBIT_Q << 1) - 1), > -1, -1, -1 > +#define _FP_NANFRAC_S                         0 > +#define _FP_NANFRAC_D                        0, 0 > +#define _FP_NANFRAC_Q                        0, 0, 0, 0 > #define _FP_NANSIGN_S                           0 > #define _FP_NANSIGN_D                          0 > #define _FP_NANSIGN_Q                          0 This did regrettably, when propagated to libgcc, regress gcc.dg/torture/builtin-math-7.c on soft-fp arm-eabi targets, currently ARMv6-M (`-march=armv6-m -mthumb') only. This is because these NANFRAC macros have now no bits set and as a result when used to construct a NaN in the semi-raw mode, they build an infinity instead. Consequently operations such as (Inf - Inf) now produce Inf rather than NaN. The change worked for the original test case, because division is made in the canonical mode, where the quiet bit is set separately, from the fp class. Here's a fix making code match the commit description quoted above, that is set the most significant bit of the significand. This is also what targets similar in this respect do. OK to apply? OK for libgcc (against libgcc/config/arm/sfp-machine.h), in particular for GCC 4.8 and 4.9? 2014-05-16 Maciej W. Rozycki PR libgcc/60166 * sysdeps/arm/soft-fp/sfp-machine.h (_FP_NANFRAC_S, _FP_NANFRAC_D) (_FP_NANSIGN_Q): Set the quiet bit. Maciej glibc-soft-fp-arm-nanfrac.diff Index: glibc-fsf-trunk-quilt/sysdeps/arm/soft-fp/sfp-machine.h =================================================================== --- glibc-fsf-trunk-quilt.orig/sysdeps/arm/soft-fp/sfp-machine.h 2014-05-16 03:25:52.000000000 +0100 +++ glibc-fsf-trunk-quilt/sysdeps/arm/soft-fp/sfp-machine.h 2014-05-16 03:31:34.451805339 +0100 @@ -21,9 +21,9 @@ #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y) #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) -#define _FP_NANFRAC_S 0 -#define _FP_NANFRAC_D 0, 0 -#define _FP_NANFRAC_Q 0, 0, 0, 0 +#define _FP_NANFRAC_S _FP_QNANBIT_S +#define _FP_NANFRAC_D _FP_QNANBIT_D, 0 +#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0 #define _FP_NANSIGN_S 0 #define _FP_NANSIGN_D 0 #define _FP_NANSIGN_Q 0