From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 5CFCF3857C64 for ; Mon, 24 Aug 2020 09:58:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5CFCF3857C64 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-180-ZWRGIDJgMvmuTvaQIZY1_w-1; Mon, 24 Aug 2020 05:58:24 -0400 X-MC-Unique: ZWRGIDJgMvmuTvaQIZY1_w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38B8A18A2244 for ; Mon, 24 Aug 2020 09:58:23 +0000 (UTC) Received: from calimero.vinschen.de (ovpn-113-99.ams2.redhat.com [10.36.113.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09D9F5D9EF for ; Mon, 24 Aug 2020 09:58:23 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id A6C14A82B8D; Mon, 24 Aug 2020 11:58:21 +0200 (CEST) Date: Mon, 24 Aug 2020 11:58:21 +0200 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH 1/2] Avoid implicit floating point conversions [v2] Message-ID: <20200824095821.GA3272@calimero.vinschen.de> Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20200821003539.942952-1-keithp@keithp.com> <20200821003539.942952-2-keithp@keithp.com> MIME-Version: 1.0 In-Reply-To: <20200821003539.942952-2-keithp@keithp.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 09:58:27 -0000 On Aug 20 17:35, Keith Packard via Newlib wrote: > These were found with clang -Wdouble-promotion and show places where > floating point values were being implicitly converted between > representations. These conversions can result in unexpected use of > double precision arithmetic. Those which are intentional all have an > explicit cast added. > [...] > diff --git a/newlib/libm/common/exp.c b/newlib/libm/common/exp.c > index 12c08c992..f3e95c6f5 100644 > --- a/newlib/libm/common/exp.c > +++ b/newlib/libm/common/exp.c > @@ -114,9 +114,9 @@ exp (double x) > return WANT_ROUNDING ? 1.0 + x : 1.0; > if (abstop >= top12 (1024.0)) > { > - if (asuint64 (x) == asuint64 (-INFINITY)) > + if (asuint64 (x) == asuint64 ((double) -INFINITY)) > return 0.0; > - if (abstop >= top12 (INFINITY)) > + if (abstop >= top12 ((double) INFINITY)) Not taking implicit compiler optimisations into account, wouldn't it make more sense to avoid the conversion altogether, using __builtin_inf() in these places? Thanks, Corinna