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: 1785454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=aP1ADyt3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QQp8Y6V8Gz20Q0 for ; Wed, 24 May 2023 07:57:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE4D43857702 for ; Tue, 23 May 2023 21:57:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE4D43857702 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684879066; bh=fDKWtDUi2AtSFsZCmfuuJOEFE9Rd1ggdKlyS+SLuRVU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=aP1ADyt36k5I6O+QlUAo2WKD8lVQ3p4nBlDXO22AADcTsV5hAkVnphuJKiGIaPoPC eLuZSDlGZE1yocoKfdcAURmMi7mKJLk1FWkh/EDsOrQJlSUTYyunDKL3A8S/YPb9hV bSQsS/svvTYFS8aP6zv/BXO9MFVeCYBIWAva7P1A= 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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)); } // }}}