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: 99442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp386813vqr; Fri, 26 May 2023 04:12:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62ie9cwSvx0O10BV5OE6trM+Y5kQSeDKmkFGOWNrsr22LBWXd5NIbvjXGb+vyrE0H2f9Qq X-Received: by 2002:a17:907:97c6:b0:970:c9f:2db3 with SMTP id js6-20020a17090797c600b009700c9f2db3mr1705502ejc.5.1685099537854; Fri, 26 May 2023 04:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685099537; cv=none; d=google.com; s=arc-20160816; b=sjPGS7RKPDKDX9ws/XGo6k+jpjM9n1DjpRkrCVtoA3+LQLlwic7O7hAqTHqYx8b2Z3 gPcA86bnOCeKW3MtWdpSJkbLy9/oxsPxpYZVoJL00QE5lPUUQuIPZbnB7upyng1AAG+W GVSHfTutPVgot1dLQm59I0pIRbwJhSWZoIan1B/pV89va186p8guliUEh/hRhPGZpDz/ Q9DhXNM+QlcEo9ACUwGZ9APbZ8xRH4CwqTgaU+/X3VBmlVWiLeA7+3+4i+qxy/c3PH7o FiSQ6unTuzvUaTVNZy/NevV6iKI2B5LDYxDyxAvofMb1WBWqP6KzaopV2pX5vvFzTDGx 2wrQ== 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=p4h0CJpYFZoQguLF1U+/rXbv65ocNehEnP8PHAY1DWQ=; b=Q7N8hbmUsqT36oF3jtId/DDtKLs/8Ua3HUKBiDxC+J5Ii5WLTqR4p5+hyMMtu+BgW5 6Ul2Ht7uqrG176Lt1Jy102peOzaoHI6P8yYfsN+/GSVkRecHVMW7o78D+1cKl+tDfvCH eEOvcGq0g8lDMQ9bAWcXOc1Ete/mD5gPidCO/TiC79D5nRtLW8syIsbufxEZ6RE/W2Te M6G7fe1SXMdgANInAIe0WbrosnDbxCBBnsENYaKRY9q5RkDpLj97wFCAZgmaGKO/MkNG KB74PX4SQkeTAHpazFsP3BUkEEH4vwyO5D+VkSS+HXRPuq5f4xcnj9yQS3zL1ADC+sl1 fJVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hnOaZIjN; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nc39-20020a1709071c2700b0096a2b6d6251si49070ejc.153.2023.05.26.04.12.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 04:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hnOaZIjN; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 BAC873858C2F for ; Fri, 26 May 2023 11:12:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAC873858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685099536; bh=p4h0CJpYFZoQguLF1U+/rXbv65ocNehEnP8PHAY1DWQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hnOaZIjNKWxF9NHVtJB4G8jOsQSsWPP3kU2p13R4xQpCdKzaivgPgS5YfaWci3O6A nY/zZyH2XqjDo0GFAjR+HXQqX7LfGM5NwGyRLQBLtqMAMfPwHJ+CE49KIti1QPyN2A DsYrQL5DvkY/HFpYRhEbca2pGXl/FYh93q6Asx5A= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766954932985356103?= X-GMAIL-MSGID: =?utf-8?q?1766954932985356103?= 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(); +}