From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40577 invoked by alias); 22 Aug 2019 16:35:19 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 40567 invoked by uid 89); 22 Aug 2019 16:35:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=overhaul, HX-Languages-Length:891, H*i:HKam9j-R5, H*i:cjde X-HELO: esa3.mentor.iphmx.com Received: from esa3.mentor.iphmx.com (HELO esa3.mentor.iphmx.com) (68.232.137.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Aug 2019 16:35:16 +0000 IronPort-SDR: 7GbomR9Ekdpss28xXXdh8AnpLbx4/PzrCW+1XIrCU5KtBIaEYTCCRbd8e/hpqy/kcAj6TpR0wN Yy7KdnmLyGY0LhUc0iQ5XNbYOiAWgn4fhvmKUtpvgASGrW97jQx7lBQm/pAJAeDl/+sZ9KAs1r MV6I/TA3Hj119D8KX5nybSLtRuOB/AHtc6X18c2/wbroF4HbQ68iTS1Vi4hXpy+VZYHZf/h7rP fjpD9EkO4FsEyappkRVOlvJuw43N3jHp0SKfEpd9Q/XR77Qv+KqaklgA9wieM/x/kOdtc+kNRn VDI= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 22 Aug 2019 08:35:14 -0800 IronPort-SDR: 9/UWv38KcCnHabMlHvzgMCFghOWiS6SDog83hZitbXTRURv9N/FSTdnLPcE6bUShOp+K/+bRl1 YwPzADDuG6R8GJuhwUHVeClGPDLMe4MfyMqT9QvFAOB7/JL9knYdxEFSbXlwUZkbYpVpcIyqbd dna/OdiWnsuxTCkEiVq/Lbo6DHWWrLhz4XDmy8DtPhuh1hyIDAsC8sdiOg036BLjNtmRJNYna3 wfMctuUg+npJ2IkWfwqJPuN9Mg/LukrmpD9kfDmzwKwHmN07PUWzZ3X4yh2T6LT1YwVRslpyAe iMs= Date: Thu, 22 Aug 2019 16:35:00 -0000 From: Joseph Myers To: Tejas Joshi CC: , Martin Jambor , Subject: Re: [PATCH] Builtin function roundeven folding implementation In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Return-Path: joseph@codesourcery.com X-SW-Source: 2019-08/txt/msg00186.txt.bz2 On Thu, 22 Aug 2019, Tejas Joshi wrote: > > I'm concerned that this would produce +0.0 for an argument of -0.5 (via > > -0.5 - 0.5 - -1.0 producing +0.0) when it needs to produce -0.0. > > Would the following overhaul be acceptable as the condition is > specialized for -0.5 and +0.5 only. This seems to solve the problem. I > did test the roundeven tests and it passes the tests. I think that would be reasonable with a comment added to explain that it's ensuring the correct sign of a zero result. > if (__builtin_copysign (1, __builtin_roundeven (-0.5)) != -1) > link_error (__LINE__); I think you should have at least four tests of sign of zero result (arguments -0.5, -0.0, 0.0 and 0.5). Probably also tests of values between +/- 0.5 and 0, e.g. test -0.25 and 0.25 as well. -- Joseph S. Myers joseph@codesourcery.com