From patchwork Tue Nov 30 20:11:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 48305 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACD84385C423 for ; Tue, 30 Nov 2021 20:14:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACD84385C423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638303264; bh=YKo/Ivohw5ZjIuEi+uGIlev8Vxd2oEbbWtjaS12d3zo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MvjOPd+y7RLemTyqHS+bGWeBJUNBmIsGxNCEs5BPMHCzHXQMeUfVDlQ9oHbP7PiMd Ltu+mHw5t05S2rNI5hFWiDFiQCyN6KOkTfnOQOIzuEXS/T2009nKlN7jDdgxH9ufMI 4KimDX/DXht3YO9yJs9LWOPLB5DiPScgowljHmXU= 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 AE7E0385C017 for ; Tue, 30 Nov 2021 20:11:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE7E0385C017 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-hUyHxP2OOSGPhZFmjeXYlQ-1; Tue, 30 Nov 2021 15:11:47 -0500 X-MC-Unique: hUyHxP2OOSGPhZFmjeXYlQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67DBB180CBFC; Tue, 30 Nov 2021 20:11:46 +0000 (UTC) Received: from localhost (unknown [10.33.36.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19A5F19724; Tue, 30 Nov 2021 20:11:45 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Skip tag dispatching for _S_relocate in C++17 Date: Tue, 30 Nov 2021 20:11:45 +0000 Message-Id: <20211130201145.107767-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux, pushed to trunk. In C++17 mode all callers of _S_relocate have already done: if constexpr (_S_use_relocate()) so we don't need to repeat that check and use tag dispatching to avoid ill-formed instantiations. libstdc++-v3/ChangeLog: * include/bits/stl_vector.h (vector::_S_do_relocate): Remove C++20 constexpr specifier. (vector::_S_relocate) [__cpp_if_constexpr]: Call __relocate_a directly without tag dispatching. --- libstdc++-v3/include/bits/stl_vector.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 4587757637e..36b2cff3d78 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -481,14 +481,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); } - static _GLIBCXX20_CONSTEXPR pointer + static pointer _S_do_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc, true_type) noexcept { return std::__relocate_a(__first, __last, __result, __alloc); } - static _GLIBCXX20_CONSTEXPR pointer + static pointer _S_do_relocate(pointer, pointer, pointer __result, _Tp_alloc_type&, false_type) noexcept { return __result; } @@ -497,8 +497,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _S_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc) noexcept { +#if __cpp_if_constexpr + // All callers have already checked _S_use_relocate() so just do it. + return std::__relocate_a(__first, __last, __result, __alloc); +#else using __do_it = __bool_constant<_S_use_relocate()>; return _S_do_relocate(__first, __last, __result, __alloc, __do_it{}); +#endif } #endif // C++11