From patchwork Thu Feb 23 08:49:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 60854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp208344wrd; Thu, 23 Feb 2023 00:57:07 -0800 (PST) X-Google-Smtp-Source: AK7set8uFGbl6UmlpNNPTZAYFRQ7rerp0E6PNmoeWR21IxLBKMS42hT5NYVf5t3zx3OpD9aZapLt X-Received: by 2002:a05:6402:515b:b0:4ac:b431:4762 with SMTP id n27-20020a056402515b00b004acb4314762mr11033849edd.23.1677142627468; Thu, 23 Feb 2023 00:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677142627; cv=none; d=google.com; s=arc-20160816; b=eUBOfUdh7edtmmoUUmxi5WkvgSInKd313GZpUhx88ciU+Rrh6Bh1ugmwvTGq2qYVGc CA8eJ1407ht3VrFwG7ml/HX/JAkD7IxQgAzXi+kyqXXF6UH1Od5q7JMmw12b45Zw8v0J hCA7jjULFYuaJLnmw/dzX3RuENArquaYojNpaxpXxG8aHTe6tYmp4m4q11RrIA991fof +oFZOcAqmgunHnE2bf+wpUbGGtJoVpZ9itbEV3L1H3NW5nqexD1k88UprpOOoUTuJBBw Rfj5Mun7v+vdKznSchc56e56twukvxljsmi7txhB+9dJz0DhY/zBXL9XDztF/O7zbAXg Twnw== 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:references:in-reply-to :organization:message-id:date:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=avctxvSsI8FjJ9QV3WjKxl9isZBLysElMayo8LCnpR8=; b=WuRDlsrUdTm4XeVbnZhWQVPqKFntM5/33Qa9JdDkxycj8xDrI1gLJfswlA0MvE6CGa svkO4K/i+Ap/Unmkqw5BlH8Ml/3ejZg1M4gRzkPWrhKrpwPWa6MgKi75gp9sV+JXJYnJ E0nGh8e4sY9A4nHLsb0tuv9cC6pFlpUGdc1fec46Oizpt//TWY+/axI+DGRA+7f/MJEY W8903cZ33r0CJtXDgRAJAcLoSrBoP0CZHiiT3s0TSyUmXBRdrRvX53/WrlUqdYpjtqL0 MO0c1E7Yas4HphPUhc5EWTTJ2vWqBMRxkLYpvfuQxVfhjx462PPZajuPFdnFvluVE+ym XOeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XDKAPH4s; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j14-20020aa7c0ce000000b004ace5dbe60fsi5507519edp.365.2023.02.23.00.57.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:57:07 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XDKAPH4s; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 B8CBE3888C5B for ; Thu, 23 Feb 2023 08:53:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8CBE3888C5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677142421; bh=avctxvSsI8FjJ9QV3WjKxl9isZBLysElMayo8LCnpR8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XDKAPH4s8KcWf1TS5pO75M7zHYOTOO2fYFdWD/UOKEJZ3hJ4HNK1zDErwu3Zt1JbF U4XPwGAjnALGI+rOSVQ35OjHdVASFczcuuUZnPnBGqlXB+Rnt0+XJsqzeUoq3ZGG46 WIFAdI4NI3LKIBVZeglqMwD3vveSVzJ3XacAhDA0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from lxmtout2.gsi.de (lxmtout2.gsi.de [140.181.3.112]) by sourceware.org (Postfix) with ESMTPS id D2BE2385800C; Thu, 23 Feb 2023 08:50:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2BE2385800C Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id 13301203E7FB; Thu, 23 Feb 2023 09:50:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lxmtout2.gsi.de Received: from lxmtout2.gsi.de ([127.0.0.1]) by localhost (lxmtout2.gsi.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ptzrUIRya55C; Thu, 23 Feb 2023 09:50:53 +0100 (CET) Received: from srvEX6.campus.gsi.de (unknown [10.10.4.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lxmtout2.gsi.de (Postfix) with ESMTPS id ED91D2027E3F; Thu, 23 Feb 2023 09:50:53 +0100 (CET) Received: from minbar.localnet (140.181.3.12) by srvEX6.campus.gsi.de (10.10.4.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Thu, 23 Feb 2023 09:50:53 +0100 To: , Subject: [PATCH 1/8] libstdc++: Simplify three helper functions into one Date: Thu, 23 Feb 2023 09:49:19 +0100 Message-ID: <7492903.EvYhyI6sBW@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research In-Reply-To: <2218250.iZASKD2KPV@minbar> References: <2218250.iZASKD2KPV@minbar> MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvex5.Campus.gsi.de (10.10.4.95) To srvEX6.campus.gsi.de (10.10.4.96) X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matthias Kretz via Gcc-patches From: Matthias Kretz Reply-To: Matthias Kretz Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758611507894769152?= X-GMAIL-MSGID: =?utf-8?q?1758611507894769152?= Broadcast is a very common function. This should reduce compile-time effort. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/108030 * include/experimental/bits/simd.h (__vector_broadcast): Implement via __vector_broadcast_impl instead of __call_with_n_evaluations + 2 lambdas. (__vector_broadcast_impl): New. --- libstdc++-v3/include/experimental/bits/simd.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- ────────────────────────────────────────────────────────────────────────── Dr. Matthias Kretz https://mattkretz.github.io GSI Helmholtz Centre for Heavy Ion Research https://gsi.de stdₓ::simd ────────────────────────────────────────────────────────────────────────── diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index 2f615d13b73..7482d109291 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -1798,15 +1798,15 @@ __to_intrin(_Tp __x) // }}} // __vector_broadcast{{{ +template + _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> + __vector_broadcast_impl(_Tp __x, index_sequence<_I...>) + { return __vector_type_t<_Tp, _Np>{((void)_I, __x)...}; } + template _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> __vector_broadcast(_Tp __x) - { - return __call_with_n_evaluations<_Np>( - [](auto... __xx) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { - return __vector_type_t<_Tp, _Np>{__xx...}; - }, [&__x](int) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x; }); - } + { return __vector_broadcast_impl<_Np, _Tp>(__x, make_index_sequence<_Np>()); } // }}} // __generate_vector{{{