From patchwork Thu Feb 23 08:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 60850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp207655wrd; Thu, 23 Feb 2023 00:54:31 -0800 (PST) X-Google-Smtp-Source: AK7set900Ectd+0nWVZMMpS2xvH5ZKXdbwfx9mVDga+2Xcu/guJAUuU5ovmpq7cw5Aa2AbmCPYPm X-Received: by 2002:a17:906:4f10:b0:88f:a236:69e6 with SMTP id t16-20020a1709064f1000b0088fa23669e6mr18436096eju.7.1677142471095; Thu, 23 Feb 2023 00:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677142471; cv=none; d=google.com; s=arc-20160816; b=WUKm72uLZYil0nTRNe6d+4EG81D4KwbTY7OhpmpsQd+RYnILBwx0mITkxWWpMEcpMc KOt6mPD9fp0z6BzIqjTGflHHQ2yNFU2s0VwMFtf8kXPM4tLSZhnjVeuYRBjixhfSpsGM LuRZCLleLSsr2BdKohtCCwHh7oMUAgUrZERDmnHE7Y7UT0g1gs6peQT2GOxYDqqVvYnB 9tuYjA8wz+YTwetKwhYYGIGMKj1pZAgPOwNqwHHzC05OQchwr3LLfYFPk5JPa6IfKFt6 hrku4sU3+nZwFgVGjFXZF1/al9O5rEAunXk+cKQdSOphfC9rsPC/sB5yvPm2koFkrduA xtZg== 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:references:in-reply-to :organization:message-id:date:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=OqSS1Y9zR7eHrdZUYiUy/Chl2CFlPpCm7ALrhpq/Xzk=; b=XuXpFA/D72jr8tTm6e1KqfSUNNrATVrYCCohjhqcornFUY5svvZ1YnkEyNZb9VbdQX GqDStgtwSs9ttfxJdWkjjURKpvbMre0qdnOSrZy8cxmlIMuvqmUcghG6oSEBP7CU+BFo ut3oMFj4z44unsVmv1cct+XatSnmv3oA4A6vpPL6WXoB/J7VwVMEO8FAqP7NVqzxg2VT HaGbB4ZhQXdrkzQLcDo9qoqUakB+PPnUpTtAiRUOSnO6YL+1K5moohYdWqHEgUDdyvgX rzxAxfKuoBoWht41Aq2j2rMpUsqGjbDTpEJGjLi0YHMxmioY/z3LUGRR1hwCQN5/E79E vhTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=y7TjdVgS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 18-20020a170906209200b008dc4d55dda4si15366224ejq.705.2023.02.23.00.54.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:54:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=y7TjdVgS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 62859384F4A0 for ; Thu, 23 Feb 2023 08:52:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62859384F4A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677142354; bh=OqSS1Y9zR7eHrdZUYiUy/Chl2CFlPpCm7ALrhpq/Xzk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=y7TjdVgSFB8gTfJbswoD4kV5n6iQ7spKoeplWc02tYUy83YENtGKaWjsBPxaJddfQ AcmfC5+Dr9PFOPOjuCKSmLXviAY/ZLEsjrRWx0uDEUffYvIdVAtvAfbkDye0wjHhsU CkxfhVrrqpFmwaatdiGB7TesK7iWXuFoczUxMiEk= 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 CD5093858C66; Thu, 23 Feb 2023 08:50:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD5093858C66 Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id 00DF02027E3F; Thu, 23 Feb 2023 09:50:46 +0100 (CET) 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 3cm_kxuGbhgb; Thu, 23 Feb 2023 09:50:45 +0100 (CET) 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 2E656203E80A; Thu, 23 Feb 2023 09:50:45 +0100 (CET) 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.25; Thu, 23 Feb 2023 09:50:44 +0100 To: , Subject: [PATCH 6/8] libstdc++: Fix formatting Date: Thu, 23 Feb 2023 09:50:02 +0100 Message-ID: <2147606.Icojqenx9y@minbar> Organization: GSI Helmholtz Centre for Heavy Ion Research In-Reply-To: <2218250.iZASKD2KPV@minbar> References: <2218250.iZASKD2KPV@minbar> 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.1 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP 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?1758611343461202639?= X-GMAIL-MSGID: =?utf-8?q?1758611343461202639?= Whitespace changes only. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h: Line breaks and indenting fixed to follow the libstdc++ standard. * include/experimental/bits/simd_builtin.h: Likewise. * include/experimental/bits/simd_fixed_size.h: Likewise. * include/experimental/bits/simd_neon.h: Likewise. * include/experimental/bits/simd_ppc.h: Likewise. * include/experimental/bits/simd_scalar.h: Likewise. * include/experimental/bits/simd_x86.h: Likewise. --- libstdc++-v3/include/experimental/bits/simd.h | 473 ++++++------ .../include/experimental/bits/simd_builtin.h | 692 +++++++++--------- .../experimental/bits/simd_fixed_size.h | 228 +++--- .../include/experimental/bits/simd_neon.h | 24 +- .../include/experimental/bits/simd_ppc.h | 3 +- .../include/experimental/bits/simd_scalar.h | 362 +++++---- .../include/experimental/bits/simd_x86.h | 90 ++- 7 files changed, 942 insertions(+), 930 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.h b/libstdc++-v3/include/experimental/bits/simd.h index 7482d109291..fb661c9657f 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -180,10 +180,7 @@ struct vector_aligned_tag template _GLIBCXX_SIMD_INTRINSIC static constexpr _Up* _S_apply(_Up* __ptr) - { - return static_cast<_Up*>( - __builtin_assume_aligned(__ptr, _S_alignment<_Tp, _Up>)); - } + { return static_cast<_Up*>( __builtin_assume_aligned(__ptr, _S_alignment<_Tp, _Up>)); } }; template struct overaligned_tag @@ -288,13 +285,15 @@ namespace __detail // expression. math_errhandling may expand to an extern symbol, in which case a constexpr value // must be guessed. template - constexpr bool __handle_fpexcept_impl(int) + constexpr bool + __handle_fpexcept_impl(int) { return math_errhandling & MATH_ERREXCEPT; } #endif // Fallback if math_errhandling doesn't work: with fast-math assume floating-point exceptions are // ignored, otherwise implement correct exception behavior. - constexpr bool __handle_fpexcept_impl(float) + constexpr bool + __handle_fpexcept_impl(float) { #if defined __FAST_MATH__ return false; @@ -749,8 +748,7 @@ struct __make_dependent // __invoke_ub{{{ template [[noreturn]] _GLIBCXX_SIMD_ALWAYS_INLINE void - __invoke_ub([[maybe_unused]] const char* __msg, - [[maybe_unused]] const _Args&... __args) + __invoke_ub([[maybe_unused]] const char* __msg, [[maybe_unused]] const _Args&... __args) { #ifdef _GLIBCXX_DEBUG_UB __builtin_fprintf(stderr, __msg, __args...); @@ -795,11 +793,14 @@ class _ExactBool const bool _M_data; public: - _GLIBCXX_SIMD_INTRINSIC constexpr _ExactBool(bool __b) : _M_data(__b) {} + _GLIBCXX_SIMD_INTRINSIC constexpr + _ExactBool(bool __b) : _M_data(__b) {} _ExactBool(int) = delete; - _GLIBCXX_SIMD_INTRINSIC constexpr operator bool() const { return _M_data; } + _GLIBCXX_SIMD_INTRINSIC constexpr + operator bool() const + { return _M_data; } }; // }}} @@ -1488,8 +1489,7 @@ struct __vector_type_n<_Tp, 1, enable_if_t<__is_vectorizable_v<_Tp>>> // else, use GNU-style builtin vector types template - struct __vector_type_n<_Tp, _Np, - enable_if_t<__is_vectorizable_v<_Tp> && _Np >= 2>> + struct __vector_type_n<_Tp, _Np, enable_if_t<__is_vectorizable_v<_Tp> && _Np >= 2>> { static constexpr size_t _S_Np2 = std::__bit_ceil(_Np * sizeof(_Tp)); @@ -1770,8 +1770,7 @@ __bit_cast(const _From __x) // }}} // __to_intrin {{{ template , - typename _R - = __intrinsic_type_t> + typename _R = __intrinsic_type_t> _GLIBCXX_SIMD_INTRINSIC constexpr _R __to_intrin(_Tp __x) { @@ -1792,9 +1791,7 @@ __to_intrin(_Tp __x) template _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, sizeof...(_Args)> __make_vector(const _Args&... __args) - { - return __vector_type_t<_Tp, sizeof...(_Args)>{static_cast<_Tp>(__args)...}; - } + { return __vector_type_t<_Tp, sizeof...(_Args)>{static_cast<_Tp>(__args)...}; } // }}} // __vector_broadcast{{{ @@ -1813,10 +1810,7 @@ __vector_broadcast(_Tp __x) template _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> __generate_vector_impl(_Gp&& __gen, index_sequence<_I...>) - { - return __vector_type_t<_Tp, _Np>{ - static_cast<_Tp>(__gen(_SizeConstant<_I>()))...}; - } + { return __vector_type_t<_Tp, _Np>{ static_cast<_Tp>(__gen(_SizeConstant<_I>()))...}; } template , typename _Gp> _GLIBCXX_SIMD_INTRINSIC constexpr _V @@ -2029,8 +2023,7 @@ __not(_Tp __a) noexcept // }}} // __concat{{{ template , - typename _R = __vector_type_t> + typename _R = __vector_type_t> constexpr _R __concat(_Tp a_, _Tp b_) { @@ -2174,8 +2167,7 @@ __zero_extend(_Tp __x) int _SplitBy, typename _Tp, typename _TVT = _VectorTraits<_Tp>, - typename _R = __vector_type_t> + typename _R = __vector_type_t> _GLIBCXX_SIMD_INTRINSIC constexpr _R __extract(_Tp __in) { @@ -2221,8 +2213,7 @@ __extract(_Tp __in) // }}} // __lo/__hi64[z]{{{ template ::value_type>> + typename _R = __vector_type8_t::value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __lo64(_Tp __x) { @@ -2232,8 +2223,7 @@ __lo64(_Tp __x) } template ::value_type>> + typename _R = __vector_type8_t::value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __hi64(_Tp __x) { @@ -2244,8 +2234,7 @@ __hi64(_Tp __x) } template ::value_type>> + typename _R = __vector_type8_t::value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __hi64z([[maybe_unused]] _Tp __x) { @@ -2356,18 +2345,15 @@ struct __bool_storage_member_type<64> // the following excludes bool via __is_vectorizable #if _GLIBCXX_SIMD_HAVE_SSE template - struct __intrinsic_type<_Tp, _Bytes, - enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 64>> + struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 64>> { static_assert(!is_same_v<_Tp, long double>, "no __intrinsic_type support for long double on x86"); - static constexpr size_t _S_VBytes = _Bytes <= 16 ? 16 - : _Bytes <= 32 ? 32 - : 64; + static constexpr size_t _S_VBytes = _Bytes <= 16 ? 16 : _Bytes <= 32 ? 32 : 64; using type [[__gnu__::__vector_size__(_S_VBytes)]] - = conditional_t, long long int, _Tp>; + = conditional_t, long long int, _Tp>; }; #endif // _GLIBCXX_SIMD_HAVE_SSE @@ -2413,16 +2399,19 @@ struct __intrinsic_type> #undef _GLIBCXX_SIMD_ARM_INTRIN template - struct __intrinsic_type<_Tp, _Bytes, - enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 16>> + struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 16>> { static constexpr int _SVecBytes = _Bytes <= 8 ? 8 : 16; + using _Ip = __int_for_sizeof_t<_Tp>; + using _Up = conditional_t< is_floating_point_v<_Tp>, _Tp, conditional_t, make_unsigned_t<_Ip>, _Ip>>; + static_assert(!is_same_v<_Tp, _Up> || _SVecBytes != _Bytes, "should use explicit specialization above"); + using type = typename __intrinsic_type<_Up, _SVecBytes>::type; }; #endif // _GLIBCXX_SIMD_HAVE_NEON @@ -2457,18 +2446,20 @@ struct __intrinsic_type_impl<_Tp> #undef _GLIBCXX_SIMD_PPC_INTRIN template - struct __intrinsic_type<_Tp, _Bytes, - enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 16>> + struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 16>> { static constexpr bool _S_is_ldouble = is_same_v<_Tp, long double>; + // allow _Tp == long double with -mlong-double-64 static_assert(!(_S_is_ldouble && sizeof(long double) > sizeof(double)), "no __intrinsic_type support for 128-bit floating point on PowerPC"); + #ifndef __VSX__ static_assert(!(is_same_v<_Tp, double> || (_S_is_ldouble && sizeof(long double) == sizeof(double))), "no __intrinsic_type support for 64-bit floating point on PowerPC w/o VSX"); #endif + using type = typename __intrinsic_type_impl< conditional_t, @@ -2489,22 +2480,29 @@ struct _SimdWrapper static constexpr size_t _S_full_size = sizeof(_BuiltinType) * __CHAR_BIT__; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper - __as_full_vector() const { return _M_data; } + __as_full_vector() const + { return _M_data; } + + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper() = default; - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper() = default; - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(_BuiltinType __k) - : _M_data(__k) {}; + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper(_BuiltinType __k) : _M_data(__k) {}; - _GLIBCXX_SIMD_INTRINSIC operator const _BuiltinType&() const + _GLIBCXX_SIMD_INTRINSIC + operator const _BuiltinType&() const { return _M_data; } - _GLIBCXX_SIMD_INTRINSIC operator _BuiltinType&() + _GLIBCXX_SIMD_INTRINSIC + operator _BuiltinType&() { return _M_data; } - _GLIBCXX_SIMD_INTRINSIC _BuiltinType __intrin() const + _GLIBCXX_SIMD_INTRINSIC _BuiltinType + __intrin() const { return _M_data; } - _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator[](size_t __i) const + _GLIBCXX_SIMD_INTRINSIC constexpr value_type + operator[](size_t __i) const { return _M_data & (_BuiltinType(1) << __i); } template @@ -2512,7 +2510,8 @@ struct _SimdWrapper operator[](_SizeConstant<__i>) const { return _M_data & (_BuiltinType(1) << __i); } - _GLIBCXX_SIMD_INTRINSIC constexpr void _M_set(size_t __i, value_type __x) + _GLIBCXX_SIMD_INTRINSIC constexpr void + _M_set(size_t __i, value_type __x) { if (__x) _M_data |= (_BuiltinType(1) << __i); @@ -2520,11 +2519,12 @@ struct _SimdWrapper _M_data &= ~(_BuiltinType(1) << __i); } - _GLIBCXX_SIMD_INTRINSIC - constexpr bool _M_is_constprop() const + _GLIBCXX_SIMD_INTRINSIC constexpr bool + _M_is_constprop() const { return __builtin_constant_p(_M_data); } - _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_none_of() const + _GLIBCXX_SIMD_INTRINSIC constexpr bool + _M_is_constprop_none_of() const { if (__builtin_constant_p(_M_data)) { @@ -2536,7 +2536,8 @@ struct _SimdWrapper return false; } - _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_all_of() const + _GLIBCXX_SIMD_INTRINSIC constexpr bool + _M_is_constprop_all_of() const { if (__builtin_constant_p(_M_data)) { @@ -2558,10 +2559,11 @@ struct _SimdWrapperBase template struct _SimdWrapperBase // no padding or no SNaNs { - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase() = default; - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase(_BuiltinType __init) - : _M_data(__init) - {} + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapperBase() = default; + + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapperBase(_BuiltinType __init) : _M_data(__init) {} _BuiltinType _M_data; }; @@ -2570,10 +2572,11 @@ struct _SimdWrapperBase struct _SimdWrapperBase // with padding that needs to // never become SNaN { - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase() : _M_data() {} - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase(_BuiltinType __init) - : _M_data(__init) - {} + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapperBase() : _M_data() {} + + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapperBase(_BuiltinType __init) : _M_data(__init) {} _BuiltinType _M_data; }; @@ -2612,24 +2615,33 @@ struct _SimdWrapper __as_full_vector() const { return _M_data; } - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(initializer_list<_Tp> __init) - : _Base(__generate_from_n_evaluations<_Width, _BuiltinType>( - [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __init.begin()[__i.value]; })) {} + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper(initializer_list<_Tp> __init) + : _Base(__generate_from_n_evaluations<_Width, _BuiltinType>( + [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { + return __init.begin()[__i.value]; + })) {} - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper() = default; - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(const _SimdWrapper&) - = default; - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(_SimdWrapper&&) = default; + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper() = default; + + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper(const _SimdWrapper&) = default; + + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper(_SimdWrapper&&) = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper& operator=(const _SimdWrapper&) = default; + _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper& operator=(_SimdWrapper&&) = default; template >, is_same<_V, __intrinsic_type_t<_Tp, _Width>>>>> - _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(_V __x) + _GLIBCXX_SIMD_INTRINSIC constexpr + _SimdWrapper(_V __x) // __vector_bitcast can convert e.g. __m128 to __vector(2) float : _Base(__vector_bitcast<_Tp, _Width>(__x)) {} @@ -2644,27 +2656,34 @@ __as_full_vector() const { return _M_data[int(__i)]; }); } - _GLIBCXX_SIMD_INTRINSIC constexpr operator const _BuiltinType&() const + _GLIBCXX_SIMD_INTRINSIC constexpr + operator const _BuiltinType&() const { return _M_data; } - _GLIBCXX_SIMD_INTRINSIC constexpr operator _BuiltinType&() + _GLIBCXX_SIMD_INTRINSIC constexpr + operator _BuiltinType&() { return _M_data; } - _GLIBCXX_SIMD_INTRINSIC constexpr _Tp operator[](size_t __i) const + _GLIBCXX_SIMD_INTRINSIC constexpr _Tp + operator[](size_t __i) const { return _M_data[__i]; } template - _GLIBCXX_SIMD_INTRINSIC constexpr _Tp operator[](_SizeConstant<__i>) const + _GLIBCXX_SIMD_INTRINSIC constexpr _Tp + operator[](_SizeConstant<__i>) const { return _M_data[__i]; } - _GLIBCXX_SIMD_INTRINSIC constexpr void _M_set(size_t __i, _Tp __x) + _GLIBCXX_SIMD_INTRINSIC constexpr void + _M_set(size_t __i, _Tp __x) { _M_data[__i] = __x; } _GLIBCXX_SIMD_INTRINSIC - constexpr bool _M_is_constprop() const + constexpr bool + _M_is_constprop() const { return __builtin_constant_p(_M_data); } - _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_none_of() const + _GLIBCXX_SIMD_INTRINSIC constexpr bool + _M_is_constprop_none_of() const { if (__builtin_constant_p(_M_data)) { @@ -2685,7 +2704,8 @@ __as_full_vector() const return false; } - _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_all_of() const + _GLIBCXX_SIMD_INTRINSIC constexpr bool + _M_is_constprop_all_of() const { if (__builtin_constant_p(_M_data)) { @@ -2883,22 +2903,14 @@ struct deduce struct rebind_simd; template - struct rebind_simd< - _Tp, simd<_Up, _Abi>, - void_t, _Abi>>> - { - using type - = simd<_Tp, simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>; - }; + struct rebind_simd<_Tp, simd<_Up, _Abi>, + void_t, _Abi>>> + { using type = simd<_Tp, simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>; }; template - struct rebind_simd< - _Tp, simd_mask<_Up, _Abi>, - void_t, _Abi>>> - { - using type - = simd_mask<_Tp, simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>; - }; + struct rebind_simd<_Tp, simd_mask<_Up, _Abi>, + void_t, _Abi>>> + { using type = simd_mask<_Tp, simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>; }; template using rebind_simd_t = typename rebind_simd<_Tp, _V>::type; @@ -2908,13 +2920,11 @@ struct rebind_simd struct resize_simd; template - struct resize_simd<_Np, simd<_Tp, _Abi>, - void_t>> + struct resize_simd<_Np, simd<_Tp, _Abi>, void_t>> { using type = simd<_Tp, simd_abi::deduce_t<_Tp, _Np, _Abi>>; }; template - struct resize_simd<_Np, simd_mask<_Tp, _Abi>, - void_t>> + struct resize_simd<_Np, simd_mask<_Tp, _Abi>, void_t>> { using type = simd_mask<_Tp, simd_abi::deduce_t<_Tp, _Np, _Abi>>; }; template @@ -2963,13 +2973,11 @@ struct is_simd_mask> // casts [simd.casts] {{{1 // static_simd_cast {{{2 -template , - typename = void> +template , typename = void> struct __static_simd_cast_return_type; template - struct __static_simd_cast_return_type, _Up, _Ap, false, - void> + struct __static_simd_cast_return_type, _Up, _Ap, false, void> : __static_simd_cast_return_type, _Up, _Ap> {}; template @@ -3284,6 +3292,7 @@ __get_lvalue(const const_where_expression& __x) public: const_where_expression(const const_where_expression&) = delete; + const_where_expression& operator=(const const_where_expression&) = delete; _GLIBCXX_SIMD_INTRINSIC const_where_expression(const _M& __kk, const _Tp& dd) @@ -3328,8 +3337,8 @@ class const_where_expression struct _Wrapper { using value_type = _V; }; protected: - using value_type = - typename conditional_t, _Wrapper, _V>::value_type; + using value_type + = typename conditional_t, _Wrapper, _V>::value_type; _GLIBCXX_SIMD_INTRINSIC friend const _M& __get_mask(const const_where_expression& __x) @@ -3426,32 +3435,32 @@ static_assert( _GLIBCXX_SIMD_OP_(>>, _S_shift_right); #undef _GLIBCXX_SIMD_OP_ - _GLIBCXX_SIMD_INTRINSIC void operator++() && + _GLIBCXX_SIMD_INTRINSIC void + operator++() && { __data(_M_value) - = _Impl::template _S_masked_unary<__increment>(__data(_M_k), - __data(_M_value)); + = _Impl::template _S_masked_unary<__increment>(__data(_M_k), __data(_M_value)); } - _GLIBCXX_SIMD_INTRINSIC void operator++(int) && + _GLIBCXX_SIMD_INTRINSIC void + operator++(int) && { __data(_M_value) - = _Impl::template _S_masked_unary<__increment>(__data(_M_k), - __data(_M_value)); + = _Impl::template _S_masked_unary<__increment>(__data(_M_k), __data(_M_value)); } - _GLIBCXX_SIMD_INTRINSIC void operator--() && + _GLIBCXX_SIMD_INTRINSIC void + operator--() && { __data(_M_value) - = _Impl::template _S_masked_unary<__decrement>(__data(_M_k), - __data(_M_value)); + = _Impl::template _S_masked_unary<__decrement>(__data(_M_k), __data(_M_value)); } - _GLIBCXX_SIMD_INTRINSIC void operator--(int) && + _GLIBCXX_SIMD_INTRINSIC void + operator--(int) && { __data(_M_value) - = _Impl::template _S_masked_unary<__decrement>(__data(_M_k), - __data(_M_value)); + = _Impl::template _S_masked_unary<__decrement>(__data(_M_k), __data(_M_value)); } // intentionally hides const_where_expression::copy_from @@ -3459,15 +3468,15 @@ static_assert( _GLIBCXX_SIMD_INTRINSIC void copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _Flags) && { - __data(_M_value) - = _Impl::_S_masked_load(__data(_M_value), __data(_M_k), - _Flags::template _S_apply<_Tp>(__mem)); + __data(_M_value) = _Impl::_S_masked_load(__data(_M_value), __data(_M_k), + _Flags::template _S_apply<_Tp>(__mem)); } }; // where_expression {{{2 template - class where_expression : public const_where_expression + class where_expression + : public const_where_expression { using _M = bool; using typename const_where_expression<_M, _Tp>::value_type; @@ -3478,12 +3487,14 @@ class where_expression : public const_where_expression where_expression(const where_expression&) = delete; where_expression& operator=(const where_expression&) = delete; - _GLIBCXX_SIMD_INTRINSIC where_expression(const _M& __kk, _Tp& dd) - : const_where_expression<_M, _Tp>(__kk, dd) {} + _GLIBCXX_SIMD_INTRINSIC + where_expression(const _M& __kk, _Tp& dd) + : const_where_expression<_M, _Tp>(__kk, dd) {} #define _GLIBCXX_SIMD_OP_(__op) \ template \ - _GLIBCXX_SIMD_INTRINSIC void operator __op(_Up&& __x)&& \ + _GLIBCXX_SIMD_INTRINSIC void \ + operator __op(_Up&& __x)&& \ { if (_M_k) _M_value __op static_cast<_Up&&>(__x); } _GLIBCXX_SIMD_OP_(=) @@ -3499,16 +3510,20 @@ class where_expression : public const_where_expression _GLIBCXX_SIMD_OP_(>>=) #undef _GLIBCXX_SIMD_OP_ - _GLIBCXX_SIMD_INTRINSIC void operator++() && + _GLIBCXX_SIMD_INTRINSIC void + operator++() && { if (_M_k) ++_M_value; } - _GLIBCXX_SIMD_INTRINSIC void operator++(int) && + _GLIBCXX_SIMD_INTRINSIC void + operator++(int) && { if (_M_k) ++_M_value; } - _GLIBCXX_SIMD_INTRINSIC void operator--() && + _GLIBCXX_SIMD_INTRINSIC void + operator--() && { if (_M_k) --_M_value; } - _GLIBCXX_SIMD_INTRINSIC void operator--(int) && + _GLIBCXX_SIMD_INTRINSIC void + operator--(int) && { if (_M_k) --_M_value; } // intentionally hides const_where_expression::copy_from @@ -3526,23 +3541,20 @@ class where_expression : public const_where_expression template _GLIBCXX_SIMD_INTRINSIC - const_where_expression, simd<_Tp, _Ap>> - where(const typename simd<_Tp, _Ap>::mask_type& __k, - const simd<_Tp, _Ap>& __value) + const_where_expression, simd<_Tp, _Ap>> + where(const typename simd<_Tp, _Ap>::mask_type& __k, const simd<_Tp, _Ap>& __value) { return {__k, __value}; } template _GLIBCXX_SIMD_INTRINSIC - where_expression, simd_mask<_Tp, _Ap>> - where(const remove_const_t>& __k, - simd_mask<_Tp, _Ap>& __value) + where_expression, simd_mask<_Tp, _Ap>> + where(const remove_const_t>& __k, simd_mask<_Tp, _Ap>& __value) { return {__k, __value}; } template _GLIBCXX_SIMD_INTRINSIC - const_where_expression, simd_mask<_Tp, _Ap>> - where(const remove_const_t>& __k, - const simd_mask<_Tp, _Ap>& __value) + const_where_expression, simd_mask<_Tp, _Ap>> + where(const remove_const_t>& __k, const simd_mask<_Tp, _Ap>& __value) { return {__k, __value}; } template @@ -3555,11 +3567,11 @@ where(_ExactBool __k, _Tp& __value) where(_ExactBool __k, const _Tp& __value) { return {__k, __value}; } - template - void where(bool __k, simd<_Tp, _Ap>& __value) = delete; +template + void where(bool __k, simd<_Tp, _Ap>& __value) = delete; - template - void where(bool __k, const simd<_Tp, _Ap>& __value) = delete; +template + void where(bool __k, const simd<_Tp, _Ap>& __value) = delete; // proposed mask iterations {{{1 namespace __proposed { @@ -3576,10 +3588,12 @@ class iterator size_t __mask; size_t __bit; - _GLIBCXX_SIMD_INTRINSIC void __next_bit() + _GLIBCXX_SIMD_INTRINSIC void + __next_bit() { __bit = __builtin_ctzl(__mask); } - _GLIBCXX_SIMD_INTRINSIC void __reset_lsb() + _GLIBCXX_SIMD_INTRINSIC void + __reset_lsb() { // 01100100 - 1 = 01100011 __mask &= (__mask - 1); @@ -3591,20 +3605,24 @@ class iterator iterator(const iterator&) = default; iterator(iterator&&) = default; - _GLIBCXX_SIMD_ALWAYS_INLINE size_t operator->() const + _GLIBCXX_SIMD_ALWAYS_INLINE size_t + operator->() const { return __bit; } - _GLIBCXX_SIMD_ALWAYS_INLINE size_t operator*() const + _GLIBCXX_SIMD_ALWAYS_INLINE size_t + operator*() const { return __bit; } - _GLIBCXX_SIMD_ALWAYS_INLINE iterator& operator++() + _GLIBCXX_SIMD_ALWAYS_INLINE iterator& + operator++() { __reset_lsb(); __next_bit(); return *this; } - _GLIBCXX_SIMD_ALWAYS_INLINE iterator operator++(int) + _GLIBCXX_SIMD_ALWAYS_INLINE iterator + operator++(int) { iterator __tmp = *this; __reset_lsb(); @@ -3612,17 +3630,21 @@ class iterator return __tmp; } - _GLIBCXX_SIMD_ALWAYS_INLINE bool operator==(const iterator& __rhs) const + _GLIBCXX_SIMD_ALWAYS_INLINE bool + operator==(const iterator& __rhs) const { return __mask == __rhs.__mask; } - _GLIBCXX_SIMD_ALWAYS_INLINE bool operator!=(const iterator& __rhs) const + _GLIBCXX_SIMD_ALWAYS_INLINE bool + operator!=(const iterator& __rhs) const { return __mask != __rhs.__mask; } }; - iterator begin() const + iterator + begin() const { return __bits.to_ullong(); } - iterator end() const + iterator + end() const { return 0; } }; @@ -3637,15 +3659,13 @@ where(const simd_mask<_Tp, _Ap>& __k) // reductions [simd.reductions] {{{1 template > _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _Tp - reduce(const simd<_Tp, _Abi>& __v, - _BinaryOperation __binary_op = _BinaryOperation()) + reduce(const simd<_Tp, _Abi>& __v, _BinaryOperation __binary_op = _BinaryOperation()) { return _Abi::_SimdImpl::_S_reduce(__v, __binary_op); } template > _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, - typename _V::value_type __identity_element, - _BinaryOperation __binary_op) + typename _V::value_type __identity_element, _BinaryOperation __binary_op) { if (__builtin_expect(none_of(__get_mask(__x)), false)) return __identity_element; @@ -3684,16 +3704,12 @@ reduce(const const_where_expression<_M, _V>& __x, bit_xor<> __binary_op) template _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _Tp hmin(const simd<_Tp, _Abi>& __v) noexcept - { - return _Abi::_SimdImpl::_S_reduce(__v, __detail::_Minimum()); - } + { return _Abi::_SimdImpl::_S_reduce(__v, __detail::_Minimum()); } template _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _Tp hmax(const simd<_Tp, _Abi>& __v) noexcept - { - return _Abi::_SimdImpl::_S_reduce(__v, __detail::_Maximum()); - } + { return _Abi::_SimdImpl::_S_reduce(__v, __detail::_Maximum()); } template _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR @@ -3761,8 +3777,7 @@ minmax(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) template _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> - clamp(const simd<_Tp, _Ap>& __v, const simd<_Tp, _Ap>& __lo, - const simd<_Tp, _Ap>& __hi) + clamp(const simd<_Tp, _Ap>& __v, const simd<_Tp, _Ap>& __lo, const simd<_Tp, _Ap>& __hi) { using _Impl = typename _Ap::_SimdImpl; return {__private_init, @@ -3783,8 +3798,7 @@ clamp(const simd<_Tp, _Ap>& __v, const simd<_Tp, _Ap>& __lo, _SimdWrapper<_Tp, _Np / _Total * _Combine> __extract_part(const _SimdWrapper<_Tp, _Np> __x); -template +template _GLIBCXX_SIMD_INTRINSIC auto __extract_part(const _SimdTuple<_Tp, _A0, _As...>& __x); @@ -3794,7 +3808,8 @@ clamp(const simd<_Tp, _Ap>& __v, const simd<_Tp, _Ap>& __lo, struct _SizeList { template - static constexpr size_t _S_at(_SizeConstant<_I> = {}) + static constexpr size_t + _S_at(_SizeConstant<_I> = {}) { if constexpr (_I == 0) return _V0; @@ -3803,7 +3818,8 @@ struct _SizeList } template - static constexpr auto _S_before(_SizeConstant<_I> = {}) + static constexpr auto + _S_before(_SizeConstant<_I> = {}) { if constexpr (_I == 0) return _SizeConstant<0>(); @@ -3813,7 +3829,8 @@ struct _SizeList } template - static constexpr auto _S_pop_front(_SizeConstant<_Np> = {}) + static constexpr auto + _S_pop_front(_SizeConstant<_Np> = {}) { if constexpr (_Np == 0) return _SizeList(); @@ -3965,8 +3982,7 @@ split(const simd& __x) // }}} // split(simd_mask) {{{ template / _V::size()> + size_t _Parts = simd_size_v / _V::size()> enable_if_t && simd_size_v == _Parts * _V::size(), array<_V, _Parts>> split(const simd_mask& __x) @@ -4131,8 +4147,7 @@ static_assert( // __store_pack_of_simd {{{ template _GLIBCXX_SIMD_INTRINSIC void - __store_pack_of_simd(char* __mem, const simd<_Tp, _A0>& __x0, - const simd<_Tp, _As>&... __xs) + __store_pack_of_simd(char* __mem, const simd<_Tp, _A0>& __x0, const simd<_Tp, _As>&... __xs) { constexpr size_t __n_bytes = sizeof(_Tp) * simd_size_v<_Tp, _A0>; __builtin_memcpy(__mem, &__data(__x0), __n_bytes); @@ -4188,7 +4203,8 @@ class _SmartReference int _M_index; _Up& _M_obj; - _GLIBCXX_SIMD_INTRINSIC constexpr _ValueType _M_read() const noexcept + _GLIBCXX_SIMD_INTRINSIC constexpr _ValueType + _M_read() const noexcept { if constexpr (is_arithmetic_v<_Up>) return _M_obj; @@ -4197,7 +4213,8 @@ class _SmartReference } template - _GLIBCXX_SIMD_INTRINSIC constexpr void _M_write(_Tp&& __x) const + _GLIBCXX_SIMD_INTRINSIC constexpr void + _M_write(_Tp&& __x) const { _Accessor::_S_set(_M_obj, _M_index, static_cast<_Tp&&>(__x)); } public: @@ -4207,32 +4224,32 @@ _SmartReference(_Up& __o, int __i) noexcept using value_type = _ValueType; - _GLIBCXX_SIMD_INTRINSIC _SmartReference(const _SmartReference&) = delete; + _GLIBCXX_SIMD_INTRINSIC + _SmartReference(const _SmartReference&) = delete; - _GLIBCXX_SIMD_INTRINSIC constexpr operator value_type() const noexcept + _GLIBCXX_SIMD_INTRINSIC constexpr + operator value_type() const noexcept { return _M_read(); } - template , value_type>> - _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference operator=(_Tp&& __x) && + template , value_type>> + _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference + operator=(_Tp&& __x) && { _M_write(static_cast<_Tp&&>(__x)); return {_M_obj, _M_index}; } -#define _GLIBCXX_SIMD_OP_(__op) \ - template () __op declval<_Tp>()), \ - typename = _ValuePreservingOrInt<__remove_cvref_t<_Tp>, _TT>, \ - typename = _ValuePreservingOrInt<_TT, value_type>> \ - _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference \ - operator __op##=(_Tp&& __x) && \ - { \ - const value_type& __lhs = _M_read(); \ - _M_write(__lhs __op __x); \ - return {_M_obj, _M_index}; \ +#define _GLIBCXX_SIMD_OP_(__op) \ + template () __op declval<_Tp>()), \ + typename = _ValuePreservingOrInt<__remove_cvref_t<_Tp>, _TT>, \ + typename = _ValuePreservingOrInt<_TT, value_type>> \ + _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference \ + operator __op##=(_Tp&& __x) && \ + { \ + const value_type& __lhs = _M_read(); \ + _M_write(__lhs __op __x); \ + return {_M_obj, _M_index}; \ } _GLIBCXX_SIMD_ALL_ARITHMETICS(_GLIBCXX_SIMD_OP_); _GLIBCXX_SIMD_ALL_SHIFTS(_GLIBCXX_SIMD_OP_); @@ -4240,9 +4257,9 @@ _SmartReference(_Up& __o, int __i) noexcept #undef _GLIBCXX_SIMD_OP_ template &>())> - _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference operator++() && + typename = decltype(++declval&>())> + _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference + operator++() && { value_type __x = _M_read(); _M_write(++__x); @@ -4250,9 +4267,9 @@ _SmartReference(_Up& __o, int __i) noexcept } template &>()++)> - _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator++(int) && + typename = decltype(declval&>()++)> + _GLIBCXX_SIMD_INTRINSIC constexpr value_type + operator++(int) && { const value_type __r = _M_read(); value_type __x = __r; @@ -4261,9 +4278,9 @@ _SmartReference(_Up& __o, int __i) noexcept } template &>())> - _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference operator--() && + typename = decltype(--declval&>())> + _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference + operator--() && { value_type __x = _M_read(); _M_write(--__x); @@ -4271,9 +4288,9 @@ _SmartReference(_Up& __o, int __i) noexcept } template &>()--)> - _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator--(int) && + typename = decltype(declval&>()--)> + _GLIBCXX_SIMD_INTRINSIC constexpr value_type + operator--(int) && { const value_type __r = _M_read(); value_type __x = __r; @@ -4349,7 +4366,8 @@ struct __decay_abi<__scalar_abi_wrapper<_Bytes>> template