From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79297 invoked by alias); 1 Apr 2019 19:53:22 -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 79287 invoked by uid 89); 1 Apr 2019 19:53:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=nearest, halfway, herewith, half X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Apr 2019 19:53:20 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1hB2zZ-0007QA-Uw from joseph_myers@mentor.com ; Mon, 01 Apr 2019 12:53:13 -0700 Received: from digraph.polyomino.org.uk (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Mon, 1 Apr 2019 20:53:10 +0100 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.90_1) (envelope-from ) id 1hB2zV-00071c-SH; Mon, 01 Apr 2019 19:53:09 +0000 Date: Mon, 01 Apr 2019 19:53:00 -0000 From: Joseph Myers To: Tejas Joshi CC: Subject: Re: About GSOC. 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" X-SW-Source: 2019-04/txt/msg00018.txt.bz2 On Sat, 30 Mar 2019, Tejas Joshi wrote: > Hello. > I have developed a fairly working patch for roundeven, attaching herewith. > The testcase function as follows : > > double f() > { > double x = 4.5; > double ret = __builtin_roundeven (x); > return ret; > } Tests need to be added to the testsuite, covering a range of inputs and automatically verifying that the test is optimized correctly. "Round X to nearest even integer towards zero." is not correct. The roundeven function does not round to an even integer. It rounds to the nearest integer, whether even or odd - but, if two integers are equally close, the result is even (and for any input that is not halfway between two integers, it produces the same result as round (which rounds halfway cases away from zero) - so 2.501, 3 and 3.499 round to 3, but 2.5 rounds to 2 not 3, unlike round, and 3.5 rounds to 4, as with round). The function can't rely on arguments being in the range of HOST_WIDE_INT, so it needs to examine the REAL_VALUE_TYPE representation directly to determine whether it's half way between two integers and which way to round in that case. -- Joseph S. Myers joseph@codesourcery.com