From patchwork Sun Dec 13 04:14:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 556120 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 8CA4C140313 for ; Sun, 13 Dec 2015 15:14:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PHQtZUNZ; 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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=QZYfeQs7P6oodreUszo/UqTVIDnkY6RLuKU27ebhMlGqyFRuqj v3EpUedNofGqTrRrrB1wV/etxA+/lK9KYL6qWbWeWkGM5Z5HwUxy6K2ybFvORJFe aYIknrI7vwcS+MrHK1zFGcF6FyQuF5lkamZ/K23p096FWbnX7N1M3epIg= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=wDAHWA0050EqfsIhpeQAyun1XF4=; b=PHQtZUNZqROfBjf2GuT0 UJUN/RADiCzUFS6eRKkglT4htCqqWDqQsJvV126irA621cJfbTfLd/63ioEINwpR YF7k7s3gTKRlMvSJD7eg3d1oqyfHlTXY+KmA8s6PdDXIpPo6nyGZ/Z9nFAXpJgPq Tq8FFkuhIc0ynDx7rmhjOP8= Received: (qmail 89320 invoked by alias); 13 Dec 2015 04:14:47 -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 89290 invoked by uid 89); 13 Dec 2015 04:14:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout004-public.msg.strl.va.charter.net Received: from mtaout004-public.msg.strl.va.charter.net (HELO mtaout004-public.msg.strl.va.charter.net) (68.114.190.29) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Dec 2015 04:14:44 +0000 Received: from impout004 ([68.114.189.19]) by mtaout004.msg.strl.va.charter.net (InterMail vM.9.00.021.00 201-2473-182) with ESMTP id <20151213041442.TXAU4228.mtaout004.msg.strl.va.charter.net@impout004>; Sat, 12 Dec 2015 22:14:42 -0600 Received: from quattro.localdomain ([96.41.215.23]) by impout004 with charter.net id ssEg1r00J0Wrkg001sEh6n; Sat, 12 Dec 2015 22:14:42 -0600 X-Authority-Analysis: v=2.1 cv=VONTnr/X c=1 sm=1 tr=0 a=salB9WdMPIDduBH7JsZfrA==:117 a=salB9WdMPIDduBH7JsZfrA==:17 a=hOpmn2quAAAA:8 a=r77TgQKjGQsHNAKrUKIA:9 a=mDV3o1hIAAAA:8 a=0TyCHfxRH6u7PN4turUA:9 a=QEXdDO2ut3YA:10 a=dsALL_92cxigr6H_tkEA:9 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: gfortran Cc: gcc patches From: Jerry DeLisle Subject: [PATCH, libgfortran] PR68867 numeric formatting problem in the fortran library X-Enigmail-Draft-Status: N1110 Message-ID: <566CF0AF.6060901@charter.net> Date: Sat, 12 Dec 2015 20:14:39 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Hi all, This PR is about different binary precision of quad floats on different platforms. X86 uses libquadmath with 113 bits, PowerPC uses IBM 106 bits. For list directed output we set the default decimal precision to use. Because the PowerPC has fewer significant bits, we need to adjust the formatting for kind=16 accordingly or we are just getting junk in the last few digits emitted (consistent junk). This patch reduces the width and precision via conditional compilation depending on the bit precision. Regression tested on X86_64 and PowerPC (Power7) Linux. The patch includes the necessary updates of the testsuite quad_2.f90. OK for trunk? Regards, Jerry 2015-12-12 Jerry DeLisle PR libfortran/pr68867 * io/write.c (set_fnode_default): For kind=16, set the decimal precision depending on the platform binary precision, 106 or 113. Index: gcc/testsuite/gfortran.dg/quad_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/quad_2.f90 (revision 231314) +++ gcc/testsuite/gfortran.dg/quad_2.f90 (working copy) @@ -49,18 +49,19 @@ program test_qp if (str4 /= "1.41421356237309504876") call abort() case (16) - if (str1 /= " 1.00000000000000000000000000000000000") call abort() - if (str2 /= "1.00000000000000000000000000000000000") call abort() - if (digits(1.0_qp) == 113) then ! IEEE 754 binary 128 format ! e.g. libquadmath/__float128 on i686/x86_64/ia64 + if (str1 /= " 1.00000000000000000000000000000000000") call abort() + if (str2 /= "1.00000000000000000000000000000000000") call abort() if (str3 /= " 1.41421356237309504880168872420969798") call abort() if (str4 /= "1.41421356237309504880168872420969798") call abort() else if (digits(1.0_qp) == 106) then ! IBM binary 128 format - if (str3(1:37) /= " 1.41421356237309504880168872420969") call abort() - if (str4(1:34) /= "1.41421356237309504880168872420969") call abort() + if (str1 /= " 1.0000000000000000000000000000000") call abort() + if (str2 /= "1.0000000000000000000000000000000") call abort() + if (str3(1:37) /= " 1.4142135623730950488016887242097") call abort() + if (str4(1:34) /= "1.4142135623730950488016887242097") call abort() end if ! Do a libm run-time test Index: libgfortran/io/write.c =================================================================== --- libgfortran/io/write.c (revision 231314) +++ libgfortran/io/write.c (working copy) @@ -1405,9 +1405,16 @@ set_fnode_default (st_parameter_dt *dtp, fnode *f, f->u.real.e = 4; break; case 16: + /* Adjust decimal precision depending on binary precision, 103 or 113. */ +#if GFC_REAL_16_DIGITS == 113 f->u.real.w = 45; f->u.real.d = 36; f->u.real.e = 4; +#else + f->u.real.w = 41; + f->u.real.d = 32; + f->u.real.e = 4; +#endif break; default: internal_error (&dtp->common, "bad real kind");