From patchwork Tue Mar 28 10:40:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 75977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2113565vqo; Tue, 28 Mar 2023 03:41:50 -0700 (PDT) X-Google-Smtp-Source: AKy350bvc/v9vMPC10r7NXqBcTX14ev235A0Ktg3X0Rc8htbq0e6ACGn3/luvlX3y/YhcimoHm5m X-Received: by 2002:a17:906:a1d5:b0:92c:88f9:385c with SMTP id bx21-20020a170906a1d500b0092c88f9385cmr15421501ejb.75.1680000110697; Tue, 28 Mar 2023 03:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680000110; cv=none; d=google.com; s=arc-20160816; b=YXvunMPVqBzQFVU6AtUZjrQmhrumPWZhIAupf4J3pOY7tXEmH9Y4ndSDg3Ugid8+Cz LOLnAHuRpl/siIuTDtidU0qVHXJG2QyBGV8QK2neuVorybV/sOJ6JfLg0sej9xQI0w9j GFDsYwMnFjS4csuJblhCp57s8Q3Wb0SKm2UYgQOyETzX0hs9iZvlvYe9ZLkr7uy2z9qr QMX0Wt5o8AQ9iB6Me/XoBojCoW/DaqCIhCmjis6lcLTvrqNfygD+XeJkcwwL8sFHhcYa KqfmTgxCeBYXHqCL8wDF8C9jlvheEdk6Gj6Y44N4jXhJXqfOA+gjnXanodAOWlsgyCW2 Hleg== 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:organization:message-id:date :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=mgzCxLvflqYI+HTeenrtk0NYlywSug4P/2Ly3YlJJcY=; b=mqTO/z/+KMwDPTQPj6FRe1APHB/sp2Cey6Z5k9lusV0XrNGM0aqwlAKpEabNA06tUV 4PqQGk8G9AhY+XEF3rAQSRx/VbfTW0Dt43ZpR5ooSNt0mpL7jL80Um4g/cM/xjvjTAmn 6emb2W6n6tKEiBf1wjWZ6Ae8N3na6CTBIPJ2LH9JMcgMPmZcPxGDC93Zn5xINt0jgpyO qfY86xeFnWhMm+nhKSB7EfNUhIReYAaYxel8fUbKUNDFp3oiTH3TTVwxhlmAh/e8C88i wSz5/SkvMJDRUGLBJQbmFB0JHjNc86G4CcWPMn4wlu4VCkfNDcf8frzLMPC05Wu9HU+W UXeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ewA0m6cQ; 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 hr31-20020a1709073f9f00b0093f3027f7c8si9736009ejc.802.2023.03.28.03.41.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 03:41:50 -0700 (PDT) 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=ewA0m6cQ; 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 AB2533858033 for ; Tue, 28 Mar 2023 10:41:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB2533858033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680000099; bh=mgzCxLvflqYI+HTeenrtk0NYlywSug4P/2Ly3YlJJcY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ewA0m6cQ+yiErxArgtu/citVnhWhSdWSppJxuZgE9FNk77/M1H/EAa/vtCnYZRkD6 sfJngKO+6IRDYXXizpn+1J160kLYrhVEpojTXX/6E/J3d1rr1EW/EKeiTSCVHrYOTU Psxq/UAJOoylWnu8hdb6iyw74K9JieYs+X4bCno4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from lxmtout1.gsi.de (lxmtout1.gsi.de [140.181.3.111]) by sourceware.org (Postfix) with ESMTPS id BC4103858D39; Tue, 28 Mar 2023 10:40:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC4103858D39 Received: from localhost (localhost [127.0.0.1]) by lxmtout1.gsi.de (Postfix) with ESMTP id 4CA552051046; Tue, 28 Mar 2023 12:40:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lxmtout1.gsi.de Received: from lxmtout1.gsi.de ([127.0.0.1]) by localhost (lxmtout1.gsi.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Sjm9xodSJsQr; Tue, 28 Mar 2023 12:40:52 +0200 (CEST) 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 lxmtout1.gsi.de (Postfix) with ESMTPS id 300762051040; Tue, 28 Mar 2023 12:40:52 +0200 (CEST) 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.26; Tue, 28 Mar 2023 12:40:51 +0200 To: , Subject: [PATCH] libstdc++: Add missing trait is_simd_flag_type Date: Tue, 28 Mar 2023 12:40:51 +0200 Message-ID: <5441527.e9J7NaK4W3@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvEX6.Campus.gsi.de (10.10.4.96) 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?1761607796413327511?= X-GMAIL-MSGID: =?utf-8?q?1761607796413327511?= I don't know how, but I forgot to implement the is_simd_flag_type trait. This fixes it. No new check-simd failures on x86_64-pc-linux-gnu --------------- 8< ------------------ Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (is_simd_flag_type): New. (_IsSimdFlagType): New. (copy_from, copy_to, load ctors): Constrain _Flags using _IsSimdFlagType. --- libstdc++-v3/include/experimental/bits/simd.h | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 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 4df446654ac..224153ffbaf 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -2837,6 +2837,32 @@ __determine_native_abi() } // namespace simd_abi // traits {{{1 +template + struct is_simd_flag_type + : false_type + {}; + +template <> + struct is_simd_flag_type + : true_type + {}; + +template <> + struct is_simd_flag_type + : true_type + {}; + +template + struct is_simd_flag_type> + : __bool_constant<(_Np > 0) and __has_single_bit(_Np)> + {}; + +template + inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<_Tp>::value; + +template >> + using _IsSimdFlagType = _Tp; + // is_abi_tag {{{2 template > struct is_abi_tag : false_type {}; @@ -3308,7 +3334,7 @@ __get_lvalue(const const_where_expression& __x) template [[nodiscard]] _GLIBCXX_SIMD_INTRINSIC _V - copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _Flags) const&& + copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { return {__private_init, _Impl::_S_masked_load(__data(_M_value), __data(_M_k), @@ -3317,7 +3343,7 @@ __get_lvalue(const const_where_expression& __x) template _GLIBCXX_SIMD_INTRINSIC void - copy_to(_LoadStorePtr<_Up, value_type>* __mem, _Flags) const&& + copy_to(_LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { _Impl::_S_masked_store(__data(_M_value), _Flags::template _S_apply<_V>(__mem), @@ -3363,12 +3389,12 @@ __get_lvalue(const const_where_expression& __x) template [[nodiscard]] _GLIBCXX_SIMD_INTRINSIC _V - copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _Flags) const&& + copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { return _M_k ? static_cast<_V>(__mem[0]) : _M_value; } template _GLIBCXX_SIMD_INTRINSIC void - copy_to(_LoadStorePtr<_Up, value_type>* __mem, _Flags) const&& + copy_to(_LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { if (_M_k) __mem[0] = _M_value; @@ -3466,7 +3492,7 @@ static_assert( // intentionally hides const_where_expression::copy_from template _GLIBCXX_SIMD_INTRINSIC void - copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _Flags) && + copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) && { __data(_M_value) = _Impl::_S_masked_load(__data(_M_value), __data(_M_k), _Flags::template _S_apply<_Tp>(__mem)); @@ -3529,7 +3555,7 @@ where_expression(const _M& __kk, _Tp& dd) // intentionally hides const_where_expression::copy_from template _GLIBCXX_SIMD_INTRINSIC void - copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _Flags) && + copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) && { if (_M_k) _M_value = __mem[0]; } }; @@ -4574,12 +4600,12 @@ simd_mask(const simd_mask<_Up, simd_abi::fixed_size>& __x) // load constructor {{{ template _GLIBCXX_SIMD_ALWAYS_INLINE - simd_mask(const value_type* __mem, _Flags) + simd_mask(const value_type* __mem, _IsSimdFlagType<_Flags>) : _M_data(_Impl::template _S_load<_Ip>(_Flags::template _S_apply(__mem))) {} template _GLIBCXX_SIMD_ALWAYS_INLINE - simd_mask(const value_type* __mem, simd_mask __k, _Flags) + simd_mask(const value_type* __mem, simd_mask __k, _IsSimdFlagType<_Flags>) : _M_data{} { _M_data = _Impl::_S_masked_load(_M_data, __k._M_data, @@ -4590,14 +4616,14 @@ simd_mask(const simd_mask<_Up, simd_abi::fixed_size>& __x) // loads [simd_mask.load] {{{ template _GLIBCXX_SIMD_ALWAYS_INLINE void - copy_from(const value_type* __mem, _Flags) + copy_from(const value_type* __mem, _IsSimdFlagType<_Flags>) { _M_data = _Impl::template _S_load<_Ip>(_Flags::template _S_apply(__mem)); } // }}} // stores [simd_mask.store] {{{ template _GLIBCXX_SIMD_ALWAYS_INLINE void - copy_to(value_type* __mem, _Flags) const + copy_to(value_type* __mem, _IsSimdFlagType<_Flags>) const { _Impl::_S_store(_M_data, _Flags::template _S_apply(__mem)); } // }}} @@ -5210,7 +5236,7 @@ simd(const simd<_Up, _A2>& __x) // load constructor template _GLIBCXX_SIMD_ALWAYS_INLINE - simd(const _Up* __mem, _Flags) + simd(const _Up* __mem, _IsSimdFlagType<_Flags>) : _M_data( _Impl::_S_load(_Flags::template _S_apply(__mem), _S_type_tag)) {} @@ -5218,7 +5244,7 @@ simd(const simd<_Up, _A2>& __x) // loads [simd.load] template _GLIBCXX_SIMD_ALWAYS_INLINE void - copy_from(const _Vectorizable<_Up>* __mem, _Flags) + copy_from(const _Vectorizable<_Up>* __mem, _IsSimdFlagType<_Flags>) { _M_data = static_cast( _Impl::_S_load(_Flags::template _S_apply(__mem), _S_type_tag)); @@ -5227,7 +5253,7 @@ simd(const simd<_Up, _A2>& __x) // stores [simd.store] template _GLIBCXX_SIMD_ALWAYS_INLINE void - copy_to(_Vectorizable<_Up>* __mem, _Flags) const + copy_to(_Vectorizable<_Up>* __mem, _IsSimdFlagType<_Flags>) const { _Impl::_S_store(_M_data, _Flags::template _S_apply(__mem), _S_type_tag);