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{{{ From patchwork Thu Feb 23 08:49:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 60851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp207733wrd; Thu, 23 Feb 2023 00:54:50 -0800 (PST) X-Google-Smtp-Source: AK7set+tSJEwEnlRPSsO226a6TLokoGmD/37jG2nH73DSmaIvuXlCRpJlZ6WOllTstYLlzYwV5kg X-Received: by 2002:a17:907:2d21:b0:8cf:fda0:5b9b with SMTP id gs33-20020a1709072d2100b008cffda05b9bmr18216013ejc.22.1677142490692; Thu, 23 Feb 2023 00:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677142490; cv=none; d=google.com; s=arc-20160816; b=Ti4h+kQUHNAcsST8iTU8JQcVEWRIaAbbSBFAOeoU6oZ3CpNFaYKPURf+aJM78NAmGA rQ+PMW5xPGhdKnO+3xzdc1OcjoPN1pzNt/5wIvex2oarJRRREv9/JkM03dAN+/+O4ahe W17girkMIv7TvVM2XKwT5wazBdOBqj1Vn8+sfFogCIsdJz/EQTyEXAdrgPfgHvzFRSD9 OxBTUL3xiuify5uYtm8YBThyn8M/OS4Su8cKcVWX7OjioHnuDQKrDlz21Od7yzN3sVIR NyvZKl5rXWOYJ1yKMK36VFaqW+lnol8hUR8pDtcwPD2A+t/8kQUDyKVA2vL5pBDbJyiw IDmA== 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=AgxscoKFy/CekB/YLpVJE+jSMMWy3oUOwZus4r2DXjs=; b=axo8ZG5PhNAaWT7ewIgNVfWbxc1ngZkk9WNDf2LfsSpeY1tqlDArNCcWqqTb1T+QE/ U19oObJWEXTA/YF3H0YyA6Q1e19RDPbeKx70cD4HzaAeB3XqIbwq0XCOPjlHUMOIdE72 jOKIEyQeB0u9XgJCb+ZGqa9ByjYtN11k6sXpEGvBbPHo0h1nv8J1tvIOM0IP+6UA+Yd/ XbYtupqiVGG/T8+UEXtLydqnOI0qsARdteYaZsptFArLsFEUEMeH7jYeQ0aTEEwsgEBO xK9H19AaN4CfUUGwqdNpJJx0PnyHGjQyvOx8f4iMtkILqu7C7UpAdDSPwsQp2jFHmxCq uU8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aA7crae8; 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 e28-20020a170906749c00b008d4aec3e62bsi15061387ejl.233.2023.02.23.00.54.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:54:50 -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=aA7crae8; 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 F110A383EC76 for ; Thu, 23 Feb 2023 08:52:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F110A383EC76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677142364; bh=AgxscoKFy/CekB/YLpVJE+jSMMWy3oUOwZus4r2DXjs=; 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=aA7crae86xvTyqqTYyGGF+9nToyeGL9DzxX8+BTQRT19SI/Gfu3RFK/KCyCqzDfXn 9Ovvb5byC3hn8Qt/RhUgflciDYWWPTYX01JHgw7shEuS5nj16zRIPuFv5ngFMAAK0w dsp36X5uz2gmiDmtaAbnzN6UWhL5R4umtvnBrgTg= 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 4E22A385B53E; Thu, 23 Feb 2023 08:50:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E22A385B53E Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id 76F4B2038F9E; Thu, 23 Feb 2023 09:50:53 +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 f6SPiRUlsljK; 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 5AA5F203E7FB; 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 2/8] libstdc++: Fix simd build failure on clang Date: Thu, 23 Feb 2023 09:49:29 +0100 Message-ID: <3152270.5fSG56mABF@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.1 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?1758611364362807834?= X-GMAIL-MSGID: =?utf-8?q?1758611364362807834?= Clang does not support __attribute__ on lambdas. Therefore, only set _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA if __clang__ is not defined. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/108030 * include/experimental/bits/simd_detail.h (_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA): Define as empty for __clang__. --- libstdc++-v3/include/experimental/bits/simd_detail.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- ────────────────────────────────────────────────────────────────────────── 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_detail.h b/libstdc++-v3/include/experimental/bits/simd_detail.h index a0ad10efe0f..30cc1ef0eef 100644 --- a/libstdc++-v3/include/experimental/bits/simd_detail.h +++ b/libstdc++-v3/include/experimental/bits/simd_detail.h @@ -254,15 +254,16 @@ namespace experimental #ifdef __clang__ #define _GLIBCXX_SIMD_NORMAL_MATH +#define _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA #else #define _GLIBCXX_SIMD_NORMAL_MATH \ [[__gnu__::__optimize__("finite-math-only,no-signed-zeros")]] +#define _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA __attribute__((__always_inline__)) #endif #define _GLIBCXX_SIMD_NEVER_INLINE [[__gnu__::__noinline__]] #define _GLIBCXX_SIMD_INTRINSIC \ [[__gnu__::__always_inline__, __gnu__::__artificial__]] inline #define _GLIBCXX_SIMD_ALWAYS_INLINE [[__gnu__::__always_inline__]] inline -#define _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA __attribute__((__always_inline__)) #define _GLIBCXX_SIMD_IS_UNLIKELY(__x) __builtin_expect(__x, 0) #define _GLIBCXX_SIMD_IS_LIKELY(__x) __builtin_expect(__x, 1) From patchwork Thu Feb 23 08:49:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 60853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp208337wrd; Thu, 23 Feb 2023 00:57:06 -0800 (PST) X-Google-Smtp-Source: AK7set88UQhC2DIwUWesaQMT17HCXDkqCRbAW8biK4vAjHYVqOjPMWMFol6MFvajTwDgor4SGlf+ X-Received: by 2002:a05:6402:1253:b0:4ad:7c44:c46b with SMTP id l19-20020a056402125300b004ad7c44c46bmr11875986edw.40.1677142625870; Thu, 23 Feb 2023 00:57:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677142625; cv=none; d=google.com; s=arc-20160816; b=cECvYJ2610z60UhHS6UL7sWF4Sq/Tp6oXpqeOyVKsky5gWC9ZykRj1A1StR7LiCGXM Yn6lhqfuGzMqyJ8tOgI3/jhmAjG4CKB90/RLFKZopA/6hiArdgy5tXdnX65rkbPCpBRj d9D8Ay8JFQ/XU3HYxE+E8Uq5Xa8I002XlR+Mj1uyHDFhpvd765LEjJLX9Ur4SMTKtYB/ sIXf457CRMfqnVTReqy1dhnjOUyc3SZ0S5KDzGxfp0gsYjWbMd9pi6IrDY9xhkV15OgT acKMJDwYa0csmu2GG/hBQc8DBwN6qm7bcPUkoGsBqqWeWM4UPWnZMK9428f+C/owcyB2 +R3g== 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=zX8dr5qOgmtA+vcXCkCgVpBSXm1YyZ+Dwn4bVYAREFM=; b=J0NHPtCWJiRpPXqVGNwOEhgj5OWLHr27EhLJ0piQl6parj3Mf7jTmg3gq4xA+fffW3 dpumaJ2RHoqCM23xhOmATmGe0iZIHRdjh/1V/lMZ+VYZm047Qn7kbvtj4hSqGojkMmoj qI4i8xwOnQ9ovF3FS7xZC/04pyxRLLKyg6TQwkjXlROyV5CrhPl9v7nla+BA8plS66lW Ivzr7VlfwO7cn8GA+oMaac9NNgQaogCN42XGPGz+yZ4g1olePOaL19RIDTWT7YXiN7Im ievvEpL3GThxRXBagYcyLaSk7IjtWu/BqE2ukUQ+dfh5MWOS8npvF1ynenN5RieAPwdN I3QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="CaMwzUc/"; 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 e10-20020a50fb8a000000b004aef418518asi1075113edq.282.2023.02.23.00.57.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:57:05 -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="CaMwzUc/"; 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 0A6A53888832 for ; Thu, 23 Feb 2023 08:53:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A6A53888832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677142421; bh=zX8dr5qOgmtA+vcXCkCgVpBSXm1YyZ+Dwn4bVYAREFM=; 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=CaMwzUc/kO/XCW8p67xeDxwnnVl4n/CDBp1+AnvjO+kkdPgPborTGPGOEoo4pslq4 BpJ1VqL8AqlTR+reKutxr1zs7KErv5Ns1rYlRXBnvEsrM5YcmYJcfUAxsoRWAr5pmG 0CKSG8iaqxKnlPya16aNr81GDzm+RdcNh3lNWFG8= 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 A84923858C2C; Thu, 23 Feb 2023 08:50:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A84923858C2C Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id D17E4203E7E8; Thu, 23 Feb 2023 09:50:52 +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 v5SmfN7rH0Xl; Thu, 23 Feb 2023 09:50:52 +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 AE230203E7FB; Thu, 23 Feb 2023 09:50:52 +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:52 +0100 To: , Subject: [PATCH 3/8] libstdc++: More efficient masked inc-/decrement implementation Date: Thu, 23 Feb 2023 09:49:43 +0100 Message-ID: <1944554.usQuhbGJ8B@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: srvEX8.Campus.gsi.de (10.10.4.160) To srvEX6.campus.gsi.de (10.10.4.96) X-Spam-Status: No, score=-10.1 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?1758611506305645455?= X-GMAIL-MSGID: =?utf-8?q?1758611506305645455?= Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/108856 * include/experimental/bits/simd_builtin.h (_SimdImplBuiltin::_S_masked_unary): More efficient implementation of masked inc-/decrement for integers and floats without AVX2. * include/experimental/bits/simd_x86.h (_SimdImplX86::_S_masked_unary): New. Use AVX512 masked subtract builtins for masked inc-/decrement. --- .../include/experimental/bits/simd_builtin.h | 27 +++++++- .../include/experimental/bits/simd_x86.h | 68 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 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_builtin.h b/libstdc++-v3/include/experimental/bits/simd_builtin.h index 792439a81bf..4a4de4534f3 100644 --- a/libstdc++-v3/include/experimental/bits/simd_builtin.h +++ b/libstdc++-v3/include/experimental/bits/simd_builtin.h @@ -2546,8 +2546,31 @@ _S_masked_unary(const _SimdWrapper<_K, _Np> __k, _Op __op; if (__k._M_is_constprop_all_of()) return __data(__op(__vv)); - else - return _CommonImpl::_S_blend(__k, __v, __data(__op(__vv))); + else if constexpr (is_same_v<_Op, __increment>) + { + static_assert(not std::is_same_v<_K, bool>); + if constexpr (is_integral_v<_Tp>) + // Take a shortcut knowing that __k is an integer vector with values -1 or 0. + return __v._M_data - __vector_bitcast<_Tp>(__k._M_data); + else if constexpr (not __have_avx2) + return __v._M_data + + __vector_bitcast<_Tp>(__k._M_data & __builtin_bit_cast( + _K, _Tp(1))); + // starting with AVX2 it is more efficient to blend after add + } + else if constexpr (is_same_v<_Op, __decrement>) + { + static_assert(not std::is_same_v<_K, bool>); + if constexpr (is_integral_v<_Tp>) + // Take a shortcut knowing that __k is an integer vector with values -1 or 0. + return __v._M_data + __vector_bitcast<_Tp>(__k._M_data); + else if constexpr (not __have_avx2) + return __v._M_data + - __vector_bitcast<_Tp>(__k._M_data & __builtin_bit_cast( + _K, _Tp(1))); + // starting with AVX2 it is more efficient to blend after sub + } + return _CommonImpl::_S_blend(__k, __v, __data(__op(__vv))); } //}}}2 diff --git a/libstdc++-v3/include/experimental/bits/simd_x86.h b/libstdc++-v3/include/experimental/bits/simd_x86.h index dcfdc2a9496..897a67829d1 100644 --- a/libstdc++-v3/include/experimental/bits/simd_x86.h +++ b/libstdc++-v3/include/experimental/bits/simd_x86.h @@ -3462,6 +3462,74 @@ _S_islessgreater(_SimdWrapper<_Tp, _Np> __x, _SimdWrapper<_Tp, _Np> __y) } //}}} }}} + template