From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8328 invoked by alias); 22 Aug 2019 14:33:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 8319 invoked by uid 89); 22 Aug 2019 14:33:26 -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= 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 14:33:25 +0000 IronPort-SDR: L5juz82mwSeBcSCzmpX2lZ5laaMYIheQKTcV9kH7sBzEg4t5v7av60C5rY7ZYVlTExrSP3F9x5 tBdhZqprB/1dMcNg7NSeQ+zK/shQ7EEKBONdTHj/0VCX+oxiMdjPbX1jawQTxBA8O+VE7YVuT+ YP8QnZfnTU/PkjUDVwwMJVncsCa0UIdh5S78yzEE6gZfplqQXgsSVVQojaxKN/S1fQnKnVpR68 /H3J80n1OPEONsl2fdchEOYn7mPQksFBdijZp/40qIv3PNPFR7y3haLKgw8Gzm2NI+stMGDDs3 iak= Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 22 Aug 2019 06:33:19 -0800 IronPort-SDR: t9US/WzoKeDU5Wab6TFiZ3wk9SsVfCc9haW6vsSjHoL4tFLg6orv4m2fAlk30e0ydRAxK4fRac 1Y/uLS0p9RYNAIdG8sRTHTEJtXZMgbHK6OIrjHAmCbiroMji9dEuunlUgAaLel23RdM4AP63Bm EU0/r2bX6wCdHkgWMK7SV/7I3wvezn97dCuohTR5y7g2eVzIWryBVxFVe6O0J7dmZCeLvhKSRS EeEnyWWjTay/ExZC1X9ty+T/SA+HzJCXaybOXQsFvo3QjF/ihREO3iEn3e0op6Vy8qCYPslC0n F+k= Date: Thu, 22 Aug 2019 15:52:00 -0000 From: Joseph Myers To: Martin Jambor CC: Tejas Joshi , , 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/msg01574.txt.bz2 On Thu, 22 Aug 2019, Martin Jambor wrote: > +/* Round X to nearest integer, rounding halfway cases towards even. */ > + > +void > +real_roundeven (REAL_VALUE_TYPE *r, format_helper fmt, > + const REAL_VALUE_TYPE *x) > +{ > + if (is_halfway_below (x)) > + { > + do_add (r, x, &dconsthalf, x->sign); > + if (!is_even (r)) > + do_add (r, r, &dconstm1, x->sign); 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. Note that testcases for the sign of zero results need to check e.g. !!__builtin_signbit on the result, or the result of calling __builtin_copysign* to extract the sign of the result, since 0.0 == -0.0 so checking with ==, while necessary, is not sufficient in that case. -- Joseph S. Myers joseph@codesourcery.com