From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7857) id 88B273858CDB; Wed, 24 May 2023 11:06:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88B273858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684926405; bh=9dpQkUXDKSpefDLs2AmU0YUaThlJz2qYTgup+VfewYQ=; h=From:To:Subject:Date:From; b=cWbUmSiciOnHoMewGwvigHQWapcnot9NlEjLfidJIVCTVZHRQQb66zBTmKs6O28/a 00skVMldh95LWeU9MlnMq081bgB0zQ0eQnqO5Z2M2hJWADOqNfFy9PjfEThc0iXRJv MxidwmzrTW1UWZau/rrfhiqTCnwbP5nlODbLcbrI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Matthias Kretz To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-1159] libstdc++: Add missing constexpr to simd_neon X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: b4df098647b687ca4e43952ec4a198b2816732ba X-Git-Newrev: b0a483b0a011f9cbc8b25053eae809c77dae2a12 Message-Id: <20230524110645.88B273858CDB@sourceware.org> Date: Wed, 24 May 2023 11:06:45 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b0a483b0a011f9cbc8b25053eae809c77dae2a12 commit r14-1159-gb0a483b0a011f9cbc8b25053eae809c77dae2a12 Author: Matthias Kretz Date: Tue May 23 23:48:49 2023 +0200 libstdc++: Add missing constexpr to simd_neon 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. Diff: --- libstdc++-v3/include/experimental/bits/simd_neon.h | 76 ++++++++++------------ 1 file changed, 36 insertions(+), 40 deletions(-) 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 @@ template // }}} // _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)); } // }}}