From patchwork Tue May 23 21:57:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 98186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2439773vqo; Tue, 23 May 2023 14:58:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yfI/3Slsa585f+FAJ8f7V57vwh/gl0ratdlfqzIRSvJsLRI/HniOUUXjE2PdCj8Qw1sIe X-Received: by 2002:a17:906:6a0d:b0:967:3963:dab8 with SMTP id qw13-20020a1709066a0d00b009673963dab8mr16660645ejc.7.1684879104211; Tue, 23 May 2023 14:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684879104; cv=none; d=google.com; s=arc-20160816; b=wk4rOBowVjSGCoLjMzJOSVkWxRzPCF3T6jfzTxiw+DyrylsGRt20H2trLPjzzeNFoY o1OLYx/0SP0A7LJT8QMo5mnC258upAm6K6t5bcg30ZSGYqJ97h6m0q94Gv6HuZyy9fGp pEOIwPBOVNjS4u4iaV5bYjxPFxR+BGkyvPekIcKuW2r+vJMzkb7gm5A/zdBF8x4LZ3lL cA1MvlZlpHP4N/ugAkhqUXxtwTibaEA52mM/g1WwsJjtHE9lAVb6aMbQsdzLBagli4bf mWVjIBaaYfttaClQgAFz3nrQ28l4zxCF/VlKRT4OI5Zn9zZ75UnnCGWphYkVOO69GCT7 m4Kw== 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=fDKWtDUi2AtSFsZCmfuuJOEFE9Rd1ggdKlyS+SLuRVU=; b=pqJPv5OUlURAe1K48/MPNSyk2c1EABwz5YuR/pjQjkrWS/GiZqN4Swy4LJoNbmOScE VrfIgCyz+0Pru7YDiZ4oAfoWRg4n30BnN7yBt/0RKhExI9KdFfpoNFZdsBq7CJT5PZs1 Qg+PC6EAuFVNvnYwRqC+iB46lGyR7HUs8nfShdNe0V48DVjed7kUVHvtmfoy+VUR0HcA 6xxJaBSfKtOeHVHYpKAKZ5rOs2kUVwNiRqp/Sf6DYfE3kJ3uhEmsld74Egnc14XdHB6x jWR9kOC/4HRO17/gUWBR5AI3iVplH+3P2avqIBsn9KF1pSAmlMtdSHjbiHLn8uqvqDla aYwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ecQ3xIjY; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id rk11-20020a170907214b00b0096f0365aa54si909666ejb.290.2023.05.23.14.58.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 14:58:24 -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=ecQ3xIjY; 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 6C6AD385771C for ; Tue, 23 May 2023 21:58:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C6AD385771C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684879093; bh=fDKWtDUi2AtSFsZCmfuuJOEFE9Rd1ggdKlyS+SLuRVU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ecQ3xIjYK2SOnlyfxjNy20lJCRK0QfAnVZakNTNzXLFSIw3zKMF6b20Qiq0J7Jc6G PxMI+uh/ruCwpGJ2LFSZS8Vhxs+APp1+vyEacMAlFkfTAligMqbAefhQSTkIONANhu YjJB8NNEVRG7c5/jt+PRsmmdAZThTFhLmYCid8Yw= 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 2085B3858D35; Tue, 23 May 2023 21:57:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2085B3858D35 Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id DF0A02027E5B; Tue, 23 May 2023 23:57:23 +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 eF45xZVlpo3U; Tue, 23 May 2023 23:57:23 +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 BD869202AD72; Tue, 23 May 2023 23:57:23 +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, 23 May 2023 23:57:23 +0200 To: , Subject: [PATCH] libstdc++: Add missing constexpr to simd_neon Date: Tue, 23 May 2023 23:57:22 +0200 Message-ID: <6920882.e9J7NaK4W3@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research 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.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?1766723791569429056?= X-GMAIL-MSGID: =?utf-8?q?1766723791569429056?= Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd_neon.h (_S_reduce): Add constexpr and make NEON implementation conditional on not __builtin_is_constant_evaluated. --- .../include/experimental/bits/simd_neon.h | 76 +++++++++---------- 1 file changed, 36 insertions(+), 40 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_neon.h b/libstdc++-v3/include/experimental/bits/simd_neon.h index 637b121b130..8f732d7587b 100644 --- a/libstdc++-v3/include/experimental/bits/simd_neon.h +++ b/libstdc++-v3/include/experimental/bits/simd_neon.h @@ -84,50 +84,46 @@ _S_masked_store_nocvt(_SimdWrapper<_Tp, _Np> __v, _Tp* __mem, // }}} // _S_reduce {{{ template - _GLIBCXX_SIMD_INTRINSIC static _Tp + _GLIBCXX_SIMD_INTRINSIC static constexpr _Tp _S_reduce(simd<_Tp, _Abi> __x, _BinaryOperation&& __binary_op) { - constexpr size_t _Np = __x.size(); - if constexpr (sizeof(__x) == 16 && _Np >= 4 - && !_Abi::template _S_is_partial<_Tp>) - { - const auto __halves = split>>(__x); - const auto __y = __binary_op(__halves[0], __halves[1]); - return _SimdImplNeon>::_S_reduce( - __y, static_cast<_BinaryOperation&&>(__binary_op)); - } - else if constexpr (_Np == 8) - { - __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( - __vector_permute<1, 0, 3, 2, 5, 4, 7, 6>( - __x._M_data))); - __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( - __vector_permute<3, 2, 1, 0, 7, 6, 5, 4>( - __x._M_data))); - __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( - __vector_permute<7, 6, 5, 4, 3, 2, 1, 0>( - __x._M_data))); - return __x[0]; - } - else if constexpr (_Np == 4) - { - __x - = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( - __vector_permute<1, 0, 3, 2>(__x._M_data))); - __x - = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( - __vector_permute<3, 2, 1, 0>(__x._M_data))); - return __x[0]; - } - else if constexpr (_Np == 2) + if (not __builtin_is_constant_evaluated()) { - __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( - __vector_permute<1, 0>(__x._M_data))); - return __x[0]; + constexpr size_t _Np = __x.size(); + if constexpr (sizeof(__x) == 16 && _Np >= 4 + && !_Abi::template _S_is_partial<_Tp>) + { + const auto __halves = split>>(__x); + const auto __y = __binary_op(__halves[0], __halves[1]); + return _SimdImplNeon>::_S_reduce( + __y, static_cast<_BinaryOperation&&>(__binary_op)); + } + else if constexpr (_Np == 8) + { + __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( + __vector_permute<1, 0, 3, 2, 5, 4, 7, 6>(__x._M_data))); + __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( + __vector_permute<3, 2, 1, 0, 7, 6, 5, 4>(__x._M_data))); + __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( + __vector_permute<7, 6, 5, 4, 3, 2, 1, 0>(__x._M_data))); + return __x[0]; + } + else if constexpr (_Np == 4) + { + __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( + __vector_permute<1, 0, 3, 2>(__x._M_data))); + __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( + __vector_permute<3, 2, 1, 0>(__x._M_data))); + return __x[0]; + } + else if constexpr (_Np == 2) + { + __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( + __vector_permute<1, 0>(__x._M_data))); + return __x[0]; + } } - else - return _Base::_S_reduce(__x, - static_cast<_BinaryOperation&&>(__binary_op)); + return _Base::_S_reduce(__x, static_cast<_BinaryOperation&&>(__binary_op)); } // }}}