From patchwork Thu Oct 24 14:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 2001784 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Rxgq7aQI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XZ7xx5Tm7z1xtp for ; Fri, 25 Oct 2024 01:45:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04B5D3858C2B for ; Thu, 24 Oct 2024 14:45:40 +0000 (GMT) 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 ESMTP id A33FC3858D28 for ; Thu, 24 Oct 2024 14:44:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A33FC3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A33FC3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729781080; cv=none; b=th7auB7QLFboQhTJwwIUi0sacSIQWxTze+1DSlYi5WASVF2JNchoaLP9OkyGeD+GT5U21ni6jASosOaBLWn/mElperTbGTqy9xiKjhNtn6sKHULyIGWWTvO9wWRxkoOmhB3ky0EhF8qcCjBvIwg+i8ZA9vUZAtd33Ju+tX2noYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729781080; c=relaxed/simple; bh=zxdlKIEOGLnATU+jIBKR/TddNP9kWw103LZ2pZbTRCA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vs2iDeINP5MVqtUcZ5Mvt5QVM5trSjQJRlbQw90lEepIFNUpr8SJGPSY2g7lK8m7MJxWAw6mF42CaRUztGxDLJde582al9x+ktY4iS8PvOnPW26i/oL0M5BcuoBdTn31KmWPAoXRbIVxZX5F+d7p6xVjvEkcSfqE7ScRkvNe/34= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729781076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cN1ugS4WKwcrUWIANaacfwvhYO093jMbxDKNFE+5wgg=; b=Rxgq7aQIoBP/eNIxYHPbbBEIjO/yaGtKLviMoNRzKeCvRccK9pj9fvdpVVUsJ3UYxwC4xM pWF9S8tDBGZyd2N6hxCfMymm22WemFnlsMp/tOj+i+1xefLe84fQvwn1MXc4Dm8ppHTC4I f7Y4Z/Ru1ua7wGKO9IiFuVzBjgRcFoA= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-nalMHri0Pl691mng3cYRbA-1; Thu, 24 Oct 2024 10:44:33 -0400 X-MC-Unique: nalMHri0Pl691mng3cYRbA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC5551955D55; Thu, 24 Oct 2024 14:44:30 +0000 (UTC) Received: from localhost (unknown [10.42.28.5]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49FE819560A2; Thu, 24 Oct 2024 14:44:29 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] libstdc++: Fix typos in tests using macros for std::float128_t support Date: Thu, 24 Oct 2024 15:05:42 +0100 Message-ID: <20241024144427.1430030-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org These tests check `_GLIBCXX_DOUBLE_IS_IEEE_BINARY128` but that's never defined, it should be "LDOUBLE" not "DOUBLE". libstdc++-v3/ChangeLog: * testsuite/26_numerics/complex/ext_c++23.cc: Fix typo in macro. * testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc: Likewise. * testsuite/26_numerics/headers/cmath/functions_std_c++23.cc: Likewise. * testsuite/26_numerics/headers/cmath/nextafter_c++23.cc: Likewise. --- This first patch is an obvious fix for a typo, but tests still pass after fixing it, which is reassuring! I'll push it shortly. Tested powerpc64le-linux. libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc | 2 +- .../testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc | 2 +- .../testsuite/26_numerics/headers/cmath/functions_std_c++23.cc | 2 +- .../testsuite/26_numerics/headers/cmath/nextafter_c++23.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc b/libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc index 0fc3d6f1a66..5f4ff06448e 100644 --- a/libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc @@ -70,7 +70,7 @@ main() } #endif #if defined(__STDCPP_FLOAT128_T__) \ - && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) { std::float128_t p[2] = {}; diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc index 3c2377fd698..983027ff654 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc @@ -119,7 +119,7 @@ main() test_functions(); #endif #if defined(__STDCPP_FLOAT128_T__) \ - && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) test_functions(); #endif diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc index ea68ac5da75..bf07493ecd4 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc @@ -131,7 +131,7 @@ main() } #endif #if defined(__STDCPP_FLOAT128_T__) \ - && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) { std::float128_t p[128] = {}; diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc index 91767d22cc3..2d0f8017f4a 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc @@ -117,7 +117,7 @@ main () test (); #endif #if defined(__STDCPP_FLOAT128_T__) \ - && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) test (); #endif From patchwork Thu Oct 24 14:05:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 2001783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=a/QZ2kZt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XZ7xL3XdHz1xwy for ; Fri, 25 Oct 2024 01:45:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B350B3858D21 for ; Thu, 24 Oct 2024 14:45:08 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTP id 0D1113858C5F for ; Thu, 24 Oct 2024 14:44:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0D1113858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0D1113858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729781080; cv=none; b=d5j23xMHnlUAGHGG+i4Jo+x5LwQyDS9mgLGTXixqgNFb7mCBgs6Xj+VwIFY1j3+1sd4McQGRarV2s73gT3zzZobXO9Hvf37ldrsN4qifW2N0Vo8QBkWAtZ4DT7x0ytSo4adnwQDlQ3scoySUQ4D/QX4KGgG23doQiyv6ZFk19Ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729781080; c=relaxed/simple; bh=+2WVtlXXnryW8eHzHP795kkBqIM+QkRFexOWCl4JQk8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Sp7epvw240Ae8BFiQ56uMLa1ivKA/1nlM3tIt2bs6umLdIa156h6lH1mvGuEJE0qeQZ8Nh4RABU6gdwdslabQFFIvVijvI86iD/oI5RpVHOllIMHx0bbLjdJ9Yrk5khxKUF68xkyi0uPsk9yh/u2be7R4Oz6s5j1X0k3zHa/fyk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729781076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=52o5gItKyWTWcDuNY0UcVw9x9n010NcilRxROFHSJnQ=; b=a/QZ2kZtVJmKSoP0gpEjqHG48Kq4HHb32/wkaOxS89npy9LT2XNRAJdyzKW8kBojpr4G+3 mnwoIQviChTVQ1J18O6fwPcgf+DZL7B8U3DHjrWBHL3CmWlwcKfA0beI8YCnPI/1D2Uj0q x5yVUIbXz5D5hrQnRHqreHZRyBJrx2g= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-EHUS1R6-PvaK29eViuGW4Q-1; Thu, 24 Oct 2024 10:44:34 -0400 X-MC-Unique: EHUS1R6-PvaK29eViuGW4Q-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4EBA51955F42; Thu, 24 Oct 2024 14:44:33 +0000 (UTC) Received: from localhost (unknown [10.42.28.5]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B143B3000198; Thu, 24 Oct 2024 14:44:32 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 2/3] libstdc++: Define __memcpyable as true Date: Thu, 24 Oct 2024 15:05:43 +0100 Message-ID: <20241024144427.1430030-2-jwakely@redhat.com> In-Reply-To: <20241024144427.1430030-1-jwakely@redhat.com> References: <20241024144427.1430030-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This allows optimizing copying ranges of floating-point types when they have the same size and representation, e.g. between _Float32 and float when we know that float uses the same IEEE binary32 format as _Float32. On some targets double and long double both use IEEE binary64 format so we could enable memcpy between those types, but we don't have existing macros to check for that case. libstdc++-v3/ChangeLog: * include/bits/cpp_type_traits.h (__memcpyable): Add specializations for compatible floating-point types. --- Tested powerpc64le-linux. libstdc++-v3/include/bits/cpp_type_traits.h | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 2f9ce75e82c..e412f8d0770 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -472,6 +472,8 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) template struct __memcpyable_integer; // For heterogeneous types, allow memcpy between equal-sized integers. + // N.B. we cannot do the same for equal-sized enums, they're not assignable. + // We cannot do it for pointers, because derived-to-base can adjust offset. template struct __memcpyable<_Tp*, _Up*> { @@ -554,6 +556,27 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) struct __memcpyable_integer { enum { __width = 128 }; }; #endif +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + template<> + struct __memcpyable<_Float32*, float*> { enum { __value = true }; }; + template<> + struct __memcpyable { enum { __value = true }; }; +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + template<> + struct __memcpyable<_Float64*, double*> { enum { __value = true }; }; + template<> + struct __memcpyable { enum { __value = true }; }; +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + template<> + struct __memcpyable<_Float128*, long double*> { enum { __value = true }; }; + template<> + struct __memcpyable { enum { __value = true }; }; +#endif + // Whether two iterator types can be used with memcmp. // This trait only says it's well-formed to use memcmp, not that it // gives the right answer for a given algorithm. So for example, std::equal From patchwork Thu Oct 24 14:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 2001785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bJmvnJYX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XZ7yT1mGxz1xtp for ; Fri, 25 Oct 2024 01:46:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6AE723858CD1 for ; Thu, 24 Oct 2024 14:46:07 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTP id 8671D3858C48 for ; Thu, 24 Oct 2024 14:44:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8671D3858C48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8671D3858C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729781087; cv=none; b=Rf6oc2rlf3faGcAM4TJE9R9IjTWLg+r/88bW2Aj9Tp0gfw4r7OU4X7iKefYIggnjL9zbVAShcIlJArI8PXJFbdo9KksASvgoqh/YY5p1qq1yTSXe7oDuFnMQQqVZISATj9LO34Ijn4sDNaP2l3LdGMIjQF5P138rwy2UQ0BOIO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729781087; c=relaxed/simple; bh=7edcjmg1e73tKWmLIGVq4WDLcbV9f/iHq74RpSejTbI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=l6UVaG3HUNcK9j/HPFZZKpt6/wDud+K+OVrDXNm6Stowa3N7bRS8F34Rylkk/0hRSSRVMknYZ4M05nHxJyHTmbeox7rZXLoNXA7Vshy9KjZBXRTmY8rZIJ/CzS8U+yJGKg4+SJbWyJ6beKKBU8Ow/0Vtto73Uu7G2FgbiMZpiD4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729781079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gSo5IAhAnNVfd8Qkqf8bIqNiW2+1AQG2yK4OmHr7kMk=; b=bJmvnJYXqbCwgCUhP2HjXYMzrBSbuBMbnfYvz3AOAeTaNkA7uh7CEEZno7PbbRloVdaAUG u6nLbHJ8nqMoQJPDRNi4PVYkMpwYMhhib+ReIe7mMG8eymq75GxW58mPpfkl70aCKVSbOE Ee9CzMRPArZuj3KAcpH3oUuhGxO5im4= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-yF1qtTj1PM-KENPe1xYiPw-1; Thu, 24 Oct 2024 10:44:38 -0400 X-MC-Unique: yF1qtTj1PM-KENPe1xYiPw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF4F81955F54; Thu, 24 Oct 2024 14:44:35 +0000 (UTC) Received: from localhost (unknown [10.42.28.5]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 766B119560A2; Thu, 24 Oct 2024 14:44:34 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 3/3] libstdc++: Define config macros for additional IEEE formats Date: Thu, 24 Oct 2024 15:05:44 +0100 Message-ID: <20241024144427.1430030-3-jwakely@redhat.com> In-Reply-To: <20241024144427.1430030-1-jwakely@redhat.com> References: <20241024144427.1430030-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Some targets use IEEE binary64 for both double and long double, which means we could use memmove to optimize a std::copy from a range of double to a range of long double. We currently have no config macro to detect when long double is binary64, so add that to . This also adds config macros for the case where double and long double both use the same binary32 format as float, which is true for the avr target. No specializations of __memcpyable for that case are added by this patch, but they could be added later. libstdc++-v3/ChangeLog: * include/bits/c++config (_GLIBCXX_DOUBLE_IS_IEEE_BINARY32): Define. (_GLIBCXX_LDOUBLE_IS_IEEE_BINARY64): Define. (_GLIBCXX_LDOUBLE_IS_IEEE_BINARY32): Define. * include/bits/cpp_type_traits.h (__memcpyable): Define specializations when double and long double are compatible. --- Tested powerpc64le-linux. libstdc++-v3/include/bits/c++config | 21 ++++++++++++++++++--- libstdc++-v3/include/bits/cpp_type_traits.h | 7 +++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index b87a3527f24..1076803a865 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -836,25 +836,40 @@ namespace std # endif #endif -// Define if float has the IEEE binary32 format. #if __FLT_MANT_DIG__ == 24 \ && __FLT_MIN_EXP__ == -125 \ && __FLT_MAX_EXP__ == 128 +// Define if float has the IEEE binary32 format. # define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 #endif -// Define if double has the IEEE binary64 format. #if __DBL_MANT_DIG__ == 53 \ && __DBL_MIN_EXP__ == -1021 \ && __DBL_MAX_EXP__ == 1024 +// Define if double has the IEEE binary64 format. # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 +#elif __FLT_MANT_DIG__ == 24 \ + && __FLT_MIN_EXP__ == -125 \ + && __FLT_MAX_EXP__ == 128 +// Define if double has the IEEE binary32 format. +# define _GLIBCXX_DOUBLE_IS_IEEE_BINARY32 1 #endif -// Define if long double has the IEEE binary128 format. #if __LDBL_MANT_DIG__ == 113 \ && __LDBL_MIN_EXP__ == -16381 \ && __LDBL_MAX_EXP__ == 16384 +// Define if long double has the IEEE binary128 format. # define _GLIBCXX_LDOUBLE_IS_IEEE_BINARY128 1 +#elif __LDBL_MANT_DIG__ == 53 \ + && __LDBL_MIN_EXP__ == -1021 \ + && __LDBL_MAX_EXP__ == 1024 +// Define if long double has the IEEE binary64 format. +# define _GLIBCXX_LDOUBLE_IS_IEEE_BINARY64 1 +#elif __LDBL_MANT_DIG__ == 24 \ + && __LDBL_MIN_EXP__ == -125 \ + && __LDBL_MAX_EXP__ == 128 +// Define if long double has the IEEE binary32 format. +# define _GLIBCXX_LDOUBLE_IS_IEEE_BINARY32 1 #endif #if defined __cplusplus && defined __BFLT16_DIG__ diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index e412f8d0770..e5a5efece42 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -556,6 +556,13 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) struct __memcpyable_integer { enum { __width = 128 }; }; #endif +#if _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 && _GLIBCXX_LDOUBLE_IS_IEEE_BINARY64 + template<> + struct __memcpyable { enum { __value = true }; }; + template<> + struct __memcpyable { enum { __value = true }; }; +#endif + #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) template<> struct __memcpyable<_Float32*, float*> { enum { __value = true }; };