From patchwork Mon Jul 24 20:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 125180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2026267vqg; Mon, 24 Jul 2023 13:08:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlFoVAd+m1ZYKLgm2Xgn14IjjD6mvvMGB+KzuYw1WNBiHOG+Et/YFVM7Vx0iJ2htKNwO+soN X-Received: by 2002:aa7:cf06:0:b0:521:ae63:ee63 with SMTP id a6-20020aa7cf06000000b00521ae63ee63mr8456700edy.16.1690229330515; Mon, 24 Jul 2023 13:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690229330; cv=none; d=google.com; s=arc-20160816; b=EJEzZcihgKugQQJ4MaI/SHnLkai52LHQOHblk8E36GAGQ9AIYs6o9K4qI2Ne+iPG3u DGOvZ8WskSAUUxsgo+Tm3509BVrKgZ81PVpBZwvi4LZZ6joqW2ZbxrYO/Qh2CsiU0fQG GJpAvaEXQNyai1n25Gh2znvnRK5kZTt+rLHQ+2ppWJZMKbaqAmuPr07yHJ8/di3xWHk/ 3WntuRf4DFnxn2n0Z6BUkzmlt92L1Ao+84Oos2HzEXiDcDHoENTaegkhq6i5SsPhJeLw otf00AdZS6ugV12zH3EQxWh+nRPS5GHt8MrROOiqzzoL/IRpgc6PRdZZAYXELuh/ThdN S2yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=nFdqp4eVKJRTqQ/4tG4qJ45z2aKh8GsEFqW5JgbHgKg=; fh=sC8lnOfyH6gL5FYlMbZ1VDz6qVPMj/3ViLJWKNUCUgQ=; b=Rcg3zrFm/dw5KB0gJBrlGavALm4gxVHUlcfySb1rqNchz/zX/W5wwEqy5w19EBQmcA jsmRX2N5cvm8Fvh55jEgyeYzzqcKSzoY2clVzMlp7EJDNjpC/KUPS6EpyLBl/JFw/yu1 H3JBL3ZuiNarzQKtN302okLHl/8lh931W8H2S6N0j60thzH9PY0rKYMUNmyZPYEFin/+ GR3l7CkNolPSS1QPaAD6vTsq2XhtKG6VMtWocvdPoGreNdEbyxuLQvB//gI/AQLyhNnF UpMyjYr94gxj/OUuK+bGcVHKONtGL4VueizR+BS7zPM+LWRMKu9JC/yticyKbidm83UI njNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j68UQBzT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r19-20020aa7c153000000b00522206ad6ccsi3196161edp.403.2023.07.24.13.08.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 13:08:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j68UQBzT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51948385AFB6 for ; Mon, 24 Jul 2023 20:07:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51948385AFB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690229249; bh=nFdqp4eVKJRTqQ/4tG4qJ45z2aKh8GsEFqW5JgbHgKg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=j68UQBzTX2ereGSd4rGOXFZA3Wx6y3wDUNwoZWYo1WGnoNKWIdwadPnhS40Pt6R4K 2EpaUUH9VY/YC8JGUMcCxNtwfoltD6EHV2KHyRkAes1mBBOePKEGZ6cyhlMKzMWVug 0UHRjTHuNjt4JJnQKkSDGqroP+Y4c6/AQToamDns= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3198F386075C for ; Mon, 24 Jul 2023 20:06:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3198F386075C Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-mP2pFbpLONSxm-49659Mmg-1; Mon, 24 Jul 2023 16:06:40 -0400 X-MC-Unique: mP2pFbpLONSxm-49659Mmg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 060733C13501; Mon, 24 Jul 2023 20:06:40 +0000 (UTC) Received: from localhost (unknown [10.42.28.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id C376DF782D; Mon, 24 Jul 2023 20:06:39 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Reuse double overload of __convert_to_v if possible Date: Mon, 24 Jul 2023 21:05:32 +0100 Message-ID: <20230724200642.84915-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772333910872596277 X-GMAIL-MSGID: 1772333910872596277 This seems like a worthwhile change. In theory we could make it even smaller by using a symbol alias, but I'm not sure that's supported on the targets where this will actually help. Any objections? -- >8 -- For targets where double and long double have the same representation we can reuse the same __convert_to_v code for both types. This will slightly reduce the size of the compiled code in the library. libstdc++-v3/ChangeLog: * config/locale/generic/c_locale.cc (__convert_to_v): Reuse double overload for long double if possible. --- libstdc++-v3/config/locale/generic/c_locale.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc index 8849d78fdfa..866ba0361dc 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.cc +++ b/libstdc++-v3/config/locale/generic/c_locale.cc @@ -187,6 +187,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err, const __c_locale&) throw() { +#if __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ + double __d; + __convert_to_v(__s, __d, __err, __c_locale); + __v = __d; +#else // Assumes __s formatted for "C" locale. const char* __sav = __set_C_locale(); if (!__sav) @@ -233,6 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION setlocale(LC_ALL, __sav); delete [] __sav; +#endif // __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ } void