From patchwork Sat Feb 15 16:28:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1238583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519603-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=S4cbA14c; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hUJufeGs; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48KbL26qQlz9sP7 for ; Sun, 16 Feb 2020 03:29:12 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Y7BgAS7PKW2Imx9W DeU95+QQ7UrDUMe9hGazEdMmaYKymWDDMbRDPvxS0ZoFqti9ZHVJUEYLGiuBs44o ZDewlWbCggpSDr+6Kch+AMHY/iaWQPqczvem1pA6mqDbkIkSTwGHOhs8p/jOgKks WMfNVJQwMIRaow5wKK/35YEsE58= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=6N+Pv4kV+A6WlfOp6iHky4 uU8HM=; b=S4cbA14c1P0EC9hlwsnJXLQ2PeTeY61reNl+dWkWFCwfq7wMAoGmEd C5jQtOh57971iPy3GczWqSZGEBjcZNhl1dWDn21Dazy+DipCH3U8dNChh6AfNTUe dvMXGwTyNMPhGC/6tu7P/vYfwgboArcTkO6uETG1HAf4iZWC1Z+yU= Received: (qmail 10303 invoked by alias); 15 Feb 2020 16:29:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10294 invoked by uid 89); 15 Feb 2020 16:29:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=noisy X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Feb 2020 16:29:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581784143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Sztg248e1aQr9PkwTbhjcnyL5QgTYuP4MI/Xwz7avD8=; b=hUJufeGssfXf5rWjbt/POuX8hrgBIQQ3MzFnPl+3Ds07VKxQnvXIQgRJ4Y7p8z4P++neoC bl1Tv6Zxal1olWs3V6UJsGbs5+I3d2YDUVDAyeqYMxJ7/QcgRwdODnZUcxVA+oTxQeOTLw PEVD7RHnc+XTA8hi1DretOgctlSBav4= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-jFC-uKi5Mp6XzUx_k6ea7Q-1; Sat, 15 Feb 2020 11:29:01 -0500 Received: by mail-qv1-f71.google.com with SMTP id dc2so7829848qvb.7 for ; Sat, 15 Feb 2020 08:29:01 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id z6sm4078976qka.34.2020.02.15.08.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 08:29:00 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, jwakely@redhat.com, Patrick Palka Subject: [PATCH] libstdc++: Move code after an early exit constexpr if to under an else branch Date: Sat, 15 Feb 2020 11:28:55 -0500 Message-Id: <20200215162855.620492-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes This avoids instantiating dead code when the true branch of the constexpr if is taken. [ diffstat generated with -w to ignore noisy whitespace changes ] libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (__lexicographical_compare_fn::operator()): Move code after an early exit constexpr if to under an else branch. * include/bits/ranges_algobase.h (__equal_fn::operator()): Likewise. --- libstdc++-v3/include/bits/ranges_algo.h | 7 +++++-- libstdc++-v3/include/bits/ranges_algobase.h | 7 ++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index 7f8f0fb964b..ff1b40f6ace 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -3318,7 +3318,8 @@ namespace ranges std::__niter_base(std::move(__last2)), std::move(__comp), std::move(__proj1), std::move(__proj2)); - + else + { constexpr bool __sized_iters = (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>); @@ -3342,7 +3343,8 @@ namespace ranges { if (const auto __len = std::min(__d1, __d2)) { - const auto __c = std::__memcmp(__first1, __first2, __len); + const auto __c + = std::__memcmp(__first1, __first2, __len); if constexpr (is_same_v<_Comp, ranges::less>) { if (__c < 0) @@ -3378,6 +3380,7 @@ namespace ranges } return __first1 == __last1 && __first2 != __last2; } + } template - && sized_sentinel_for<_Sent2, _Iter2>); - if constexpr (__sized_iters) + else if constexpr (sized_sentinel_for<_Sent1, _Iter1> + && sized_sentinel_for<_Sent2, _Iter2>) { auto __d1 = ranges::distance(__first1, __last1); auto __d2 = ranges::distance(__first2, __last2);