From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpout2.vodafonemail.de (smtpout2.vodafonemail.de [145.253.239.133]) by sourceware.org (Postfix) with ESMTPS id D8FF93858C3A; Fri, 20 Aug 2021 20:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D8FF93858C3A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nexgo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nexgo.de Received: from smtp.vodafone.de (smtpa02.fra-mediabeam.com [10.2.0.33]) by smtpout2.vodafonemail.de (Postfix) with ESMTP id C24AF121721; Fri, 20 Aug 2021 22:31:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexgo.de; s=vfde-smtpout-mb-15sep; t=1629491502; bh=cIdq/+8EMGhwYd2NcdHH/YO4XOPH4jmVzYqdVm80Bhc=; h=From:To:Cc:References:In-Reply-To:Subject:Date; b=XfKNDGRFhqilkYoaev/vYkncudLIMGRp+WLLKESl7rise9C8TPFhyc/yNqwsLq28E SO1EwlyUOU7153PL/JjIVkF6kBS0xltoRAeBWhXqcDGRKGt1nuYDo8w+rZCvnSVsDO SVZbMC3A2j/NnZvjp7fV6zz1JdkUhUCDRuOp2llM= Received: from H270 (p5b38f1bc.dip0.t-ipconnect.de [91.56.241.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.vodafone.de (Postfix) with ESMTPSA id 04C231404B0; Fri, 20 Aug 2021 20:31:41 +0000 (UTC) Message-ID: <2246A49E9E024DDBB9AF9C212B29712A@H270> From: "Stefan Kanthak" To: "Joseph Myers" Cc: "Szabolcs Nagy" , "Adhemerval Zanella" , , References: <20210818125119.GH25257@arm.com> <741b2c48-a754-51c5-cb72-a2f97795e30f@linaro.org> In-Reply-To: Subject: Re: [PATCH/2nd version] Re: nextafter() about an order of magnitude slower than trivial implementation Date: Fri, 20 Aug 2021 22:19:20 +0200 Organization: Me, myself & IT MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.24158 X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 1721 X-purgate-ID: 155817::1629491502-000006E4-47D3ACD5/0/0 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2021 20:31:55 -0000 "Joseph Myers" wrote: > On Fri, 20 Aug 2021, Stefan Kanthak wrote: > >> if(ax > 0x7ffull << 53) /* x is nan */ >> return x; >> if(ay > 0x7ffull << 53) /* y is nan */ >> return y; > > How has this been tested? I'd have expected it to fail the nextafter > tests in the glibc testsuite (libm-test-nextafter.inc), because they > verify that sNaN arguments produce a qNaN result with the "invalid" > exception raised, and this looks like it would just return an sNaN > argument unchanged. It doesn't look like it would, it REALLY does! As I explicitly wrote, my changes avoid FP operations if possible. | If x or y is NaN, a NaN shall be returned. I choose to return the argument NaN, what both POSIX and ISO C allow. If my mind serves me well, one of the former editions even stated "If an argument is NaN, this argument shall be returned". This may but be influenced/spoiled by | If either x or y is a NAN, then the return value is one of the input NANs. If that bothers you, change these 4 lines to either if(ax > 0x7ffull << 53) /* x is nan */ return 0.0 + x; if(ay > 0x7ffull << 53) /* y is nan */ return 0.0 + y; (the addition has eventually to be guarded from optimisation) or if(ax > 0x7ffull << 53 /* x is nan */ || ay > 0x7ffull << 53) /* y is nan */ return x + y; whatever you like best. Stefan