From patchwork Fri May 26 11:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 70158 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 3F86B385842A for ; Fri, 26 May 2023 11:12:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F86B385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685099521; bh=p4h0CJpYFZoQguLF1U+/rXbv65ocNehEnP8PHAY1DWQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lZiIuW0uUjWXtDxZrf3GE4QqkRY6sWRDBOjydhQG/qUgteVD0QkBIOLzIBhc3m2i+ gWO9gBcvi+n2jkSxyvk2F6b7giiU9xjo17x1bPdtIy7FI8fcGl6NIBj1g2OyLnTqcF K5/7akshOmqrrTN3sKCEoRGnwnFQlyOPC6+REXpY= 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 C13FE3858D3C; Fri, 26 May 2023 11:10:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C13FE3858D3C Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id B5A7C203E7ED; Fri, 26 May 2023 13:10:48 +0200 (CEST) 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 OmVfBetwJBT0; Fri, 26 May 2023 13:10:48 +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 lxmtout2.gsi.de (Postfix) with ESMTPS id 9BE40203E7E7; Fri, 26 May 2023 13:10:48 +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; Fri, 26 May 2023 13:10:48 +0200 To: , Subject: [PATCH] libstdc++: Correct NTTP and simd_mask ctor call Date: Fri, 26 May 2023 13:10:47 +0200 Message-ID: <25353264.6Emhk5qWAg@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research MIME-Version: 1.0 X-Originating-IP: [140.181.3.12] X-ClientProxiedBy: srvEX7.Campus.gsi.de (10.10.4.97) 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, T_SCC_BODY_TEXT_LINE 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" OK for master and all backports (after 11.4 is done)? tested on powerpc64le-linux-gnu and x86_64-pc-linux-gnu ----------- 8< ------------ Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/109822 * include/experimental/bits/simd.h (to_native): Use int NTTP as specified in PTS2. (to_compatible): Likewise. Add missing tag to call mask generator ctor. * testsuite/experimental/simd/pr109822_cast_functions.cc: New test. --- libstdc++-v3/include/experimental/bits/simd.h | 7 ++- .../simd/pr109822_cast_functions.cc | 63 +++++++++++++++++++ 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 libstdc++-v3/testsuite/experimental/simd/ pr109822_cast_functions.cc -- ────────────────────────────────────────────────────────────────────────── 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 26f08f83ab0..f94b8361ab0 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -3304,7 +3304,7 @@ to_native(const fixed_size_simd<_Tp, _Np>& __x) return {__mem, vector_aligned}; } -template +template _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == native_simd_mask<_Tp>::size()), native_simd_mask<_Tp>> to_native(const fixed_size_simd_mask<_Tp, _Np>& __x) @@ -3315,7 +3315,7 @@ to_native(const fixed_size_simd_mask<_Tp, _Np>& __x) } // to_compatible {{{2 -template +template _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == simd<_Tp>::size()), simd<_Tp>> to_compatible(const simd<_Tp, simd_abi::fixed_size<_Np>>& __x) { @@ -3324,12 +3324,13 @@ to_compatible(const simd<_Tp, simd_abi::fixed_size<_Np>>& __x) return {__mem, vector_aligned}; } -template +template _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == simd_mask<_Tp>::size()), simd_mask<_Tp>> to_compatible(const simd_mask<_Tp, simd_abi::fixed_size<_Np>>& __x) { return simd_mask<_Tp>( + __private_init, [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); } diff --git a/libstdc++-v3/testsuite/experimental/simd/pr109822_cast_functions.cc b/libstdc++-v3/testsuite/experimental/simd/pr109822_cast_functions.cc new file mode 100644 index 00000000000..3deafbf7a1f --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/simd/pr109822_cast_functions.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include + +namespace stdx = std::experimental; + +template + void + test01() + { + using M = typename V::mask_type; + [[maybe_unused]] auto x = to_fixed_size(V()); + [[maybe_unused]] auto k = to_fixed_size(M()); + if constexpr (stdx::simd::size() == V::size()) + { + [[maybe_unused]] auto xx = to_compatible(x); + [[maybe_unused]] auto kk = to_compatible(k); + x = to_fixed_size(xx); + k = to_fixed_size(kk); + } + if constexpr (stdx::native_simd::size() == V::size()) + { + [[maybe_unused]] auto xx = to_native(x); + [[maybe_unused]] auto kk = to_native(k); + x = to_fixed_size(xx); + k = to_fixed_size(kk); + } + } + +template + void + iterate_abis() + { + test01>(); + test01>(); + test01>(); + test01>(); + test01 - 4>>(); + } + +int +main() +{ + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); +}