From patchwork Thu Feb 23 08:49:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kretz X-Patchwork-Id: 60852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp208267wrd; Thu, 23 Feb 2023 00:56:48 -0800 (PST) X-Google-Smtp-Source: AK7set/rACWnWYFGkakog1RAJQZHKlZIzmUQPfAfNh80HdqJABkPFrMysNk3jCUzlBpEkjYUPOxN X-Received: by 2002:a17:906:9399:b0:87e:a34b:9e2b with SMTP id l25-20020a170906939900b0087ea34b9e2bmr18451681ejx.28.1677142608065; Thu, 23 Feb 2023 00:56:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677142608; cv=none; d=google.com; s=arc-20160816; b=Ws0jX2tMutn5VNb+8ZAgplUOVa6rR57WyvPoOhgJ36fqpaHFXNryyYdxngW7yu3wbB e8KEG5bb7njIGJb/tdiaEwH9ffHWmXoLfo34s4XSkz+nR8Ugr2UuFrCCpHEde5iiQzQU zBetz1joLgNBxzL9WC61/VLbzTOh/7rtEm7KwQTuHFyWD3hZqbX+OmomButXwjtUs8D8 3PZTMPG2qaItg7anfY9Szq4rkQn5bEm320HMXp/NsNqwDPh5J61WYqxZdSUG1a+p6Zmz LuvQBtGHINiLiVjRQa/mfOsEIoDL0h7urVmJ1e83dQ6Yn1EwED4mmdp0DHNuQL7U9c1U 92Zg== 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=N6VWp/SLkMzSF2VfNqAfBjlSjVTVNXlRVAM6YHACzE4=; b=YGrdGma/FVW1/cl65iQdr41jl3y2DHgsJ/emid1eNjMDlxNVQwckrFLEC4WGbLO5C4 iRAGodCMYJK5ehh8aVWGUE3daxRnP0YciCl+TRYrkKDa3NA3h1BqGAx58llCUnjKqYYM mYPUflHPYsJroLMDfF7Veu9651oxkIA3ecQAeMulfuTbYme1Vq7kcGc4vTlnqle0rYOV DO93YLdphuApfA4Cpp/KLomx6vCg5krrJpuo8+jXQderJ3yrhvT1vkkCKzVOpgTNlI7N N2xYJy4xn5dscY2iwJiAHQ3p6/mBpOLUwN89couawFHOOLXVvLGKa3ibVt7mBtxY/hZ3 DCNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K4w9NzrO; 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 fu35-20020a170907b02300b008e077a2f418si7229405ejc.165.2023.02.23.00.56.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:56:48 -0800 (PST) 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=K4w9NzrO; 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 6A4B73884526 for ; Thu, 23 Feb 2023 08:53:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A4B73884526 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677142413; bh=N6VWp/SLkMzSF2VfNqAfBjlSjVTVNXlRVAM6YHACzE4=; 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=K4w9NzrOVcffw8A4Hl9374Jq549Yb3kql5ZukMLD/vxGPV0kqkK47r9SlsOuIm9FR 9OaOzD50TPMUbef42tQcP+VjYOjOwuxRlpIdPX3Es5rQaHmIPrNAxSl/bw7AbavW73 DosFc+vd5enUhWB2XjkmZHdImDSTbWg6+PkPum54= 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 F178B385B524; Thu, 23 Feb 2023 08:50:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F178B385B524 Received: from localhost (localhost [127.0.0.1]) by lxmtout2.gsi.de (Postfix) with ESMTP id 1D2302038F83; Thu, 23 Feb 2023 09:50:51 +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 EIkot24M8_ly; Thu, 23 Feb 2023 09:50:51 +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 005352027E52; Thu, 23 Feb 2023 09:50:50 +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:50 +0100 To: , Subject: [PATCH 5/8] libstdc++: Always-inline most of non-cmath fixed_size implementation Date: Thu, 23 Feb 2023 09:49:57 +0100 Message-ID: <3667544.MHq7AAxBmi@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: srvEX7.Campus.gsi.de (10.10.4.97) 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?1758611487342424362?= X-GMAIL-MSGID: =?utf-8?q?1758611487342424362?= For simd, the inlining behavior should be similar to builtin types. (No operator on buitin types is ever translated into a function call.) Therefore, always_inline is the right choice (i.e. inline on -O0 as well). Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/108030 * include/experimental/bits/simd_fixed_size.h (_SimdImplFixedSize::_S_broadcast): Replace inline with _GLIBCXX_SIMD_INTRINSIC. (_SimdImplFixedSize::_S_generate): Likewise. (_SimdImplFixedSize::_S_load): Likewise. (_SimdImplFixedSize::_S_masked_load): Likewise. (_SimdImplFixedSize::_S_store): Likewise. (_SimdImplFixedSize::_S_masked_store): Likewise. (_SimdImplFixedSize::_S_min): Likewise. (_SimdImplFixedSize::_S_max): Likewise. (_SimdImplFixedSize::_S_complement): Likewise. (_SimdImplFixedSize::_S_unary_minus): Likewise. (_SimdImplFixedSize::_S_plus): Likewise. (_SimdImplFixedSize::_S_minus): Likewise. (_SimdImplFixedSize::_S_multiplies): Likewise. (_SimdImplFixedSize::_S_divides): Likewise. (_SimdImplFixedSize::_S_modulus): Likewise. (_SimdImplFixedSize::_S_bit_and): Likewise. (_SimdImplFixedSize::_S_bit_or): Likewise. (_SimdImplFixedSize::_S_bit_xor): Likewise. (_SimdImplFixedSize::_S_bit_shift_left): Likewise. (_SimdImplFixedSize::_S_bit_shift_right): Likewise. (_SimdImplFixedSize::_S_remquo): Add inline keyword (to be explicit about not always-inline, yet). (_SimdImplFixedSize::_S_isinf): Likewise. (_SimdImplFixedSize::_S_isfinite): Likewise. (_SimdImplFixedSize::_S_isnan): Likewise. (_SimdImplFixedSize::_S_isnormal): Likewise. (_SimdImplFixedSize::_S_signbit): Likewise. --- .../experimental/bits/simd_fixed_size.h | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 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_fixed_size.h b/libstdc++-v3/include/experimental/bits/simd_fixed_size.h index 3ac6eaa3f6b..88a9b27e359 100644 --- a/libstdc++-v3/include/experimental/bits/simd_fixed_size.h +++ b/libstdc++-v3/include/experimental/bits/simd_fixed_size.h @@ -1284,7 +1284,8 @@ struct _SimdImplFixedSize // broadcast {{{2 template - static constexpr inline _SimdMember<_Tp> _S_broadcast(_Tp __x) noexcept + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdMember<_Tp> + _S_broadcast(_Tp __x) noexcept { return _SimdMember<_Tp>::_S_generate( [&](auto __meta) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { @@ -1294,8 +1295,8 @@ struct _SimdImplFixedSize // _S_generator {{{2 template - static constexpr inline _SimdMember<_Tp> _S_generator(_Fp&& __gen, - _TypeTag<_Tp>) + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdMember<_Tp> + _S_generator(_Fp&& __gen, _TypeTag<_Tp>) { return _SimdMember<_Tp>::_S_generate( [&__gen](auto __meta) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { @@ -1310,8 +1311,8 @@ struct _SimdImplFixedSize // _S_load {{{2 template - static inline _SimdMember<_Tp> _S_load(const _Up* __mem, - _TypeTag<_Tp>) noexcept + _GLIBCXX_SIMD_INTRINSIC static _SimdMember<_Tp> + _S_load(const _Up* __mem, _TypeTag<_Tp>) noexcept { return _SimdMember<_Tp>::_S_generate( [&](auto __meta) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { @@ -1321,7 +1322,7 @@ struct _SimdImplFixedSize // _S_masked_load {{{2 template - static inline _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static _SimdTuple<_Tp, _As...> _S_masked_load(const _SimdTuple<_Tp, _As...>& __old, const _MaskMember __bits, const _Up* __mem) noexcept { @@ -1344,8 +1345,8 @@ _S_masked_load(const _SimdTuple<_Tp, _As...>& __old, // _S_store {{{2 template - static inline void _S_store(const _SimdMember<_Tp>& __v, _Up* __mem, - _TypeTag<_Tp>) noexcept + _GLIBCXX_SIMD_INTRINSIC static void + _S_store(const _SimdMember<_Tp>& __v, _Up* __mem, _TypeTag<_Tp>) noexcept { __for_each(__v, [&](auto __meta, auto __native) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { __meta._S_store(__native, &__mem[__meta._S_offset], _TypeTag<_Tp>()); @@ -1354,9 +1355,9 @@ _S_masked_load(const _SimdTuple<_Tp, _As...>& __old, // _S_masked_store {{{2 template - static inline void _S_masked_store(const _SimdTuple<_Tp, _As...>& __v, - _Up* __mem, - const _MaskMember __bits) noexcept + _GLIBCXX_SIMD_INTRINSIC static void + _S_masked_store(const _SimdTuple<_Tp, _As...>& __v, _Up* __mem, + const _MaskMember __bits) noexcept { __for_each(__v, [&](auto __meta, auto __native) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { if (__meta._S_submask(__bits).any()) @@ -1464,7 +1465,7 @@ __for_each( // _S_min, _S_max {{{2 template - static inline constexpr _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> _S_min(const _SimdTuple<_Tp, _As...>& __a, const _SimdTuple<_Tp, _As...>& __b) { @@ -1476,7 +1477,7 @@ _S_min(const _SimdTuple<_Tp, _As...>& __a, } template - static inline constexpr _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> _S_max(const _SimdTuple<_Tp, _As...>& __a, const _SimdTuple<_Tp, _As...>& __b) { @@ -1489,7 +1490,7 @@ _S_max(const _SimdTuple<_Tp, _As...>& __a, // _S_complement {{{2 template - static inline constexpr _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> _S_complement(const _SimdTuple<_Tp, _As...>& __x) noexcept { return __x._M_apply_per_chunk( @@ -1500,7 +1501,7 @@ _S_complement(const _SimdTuple<_Tp, _As...>& __x) noexcept // _S_unary_minus {{{2 template - static inline constexpr _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> _S_unary_minus(const _SimdTuple<_Tp, _As...>& __x) noexcept { return __x._M_apply_per_chunk( @@ -1513,7 +1514,7 @@ _S_unary_minus(const _SimdTuple<_Tp, _As...>& __x) noexcept #define _GLIBCXX_SIMD_FIXED_OP(name_, op_) \ template \ - static inline constexpr _SimdTuple<_Tp, _As...> name_( \ + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> name_( \ const _SimdTuple<_Tp, _As...>& __x, const _SimdTuple<_Tp, _As...>& __y) \ { \ return __x._M_apply_per_chunk( \ @@ -1536,7 +1537,7 @@ _S_unary_minus(const _SimdTuple<_Tp, _As...>& __x) noexcept #undef _GLIBCXX_SIMD_FIXED_OP template - static inline constexpr _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> _S_bit_shift_left(const _SimdTuple<_Tp, _As...>& __x, int __y) { return __x._M_apply_per_chunk( @@ -1546,7 +1547,7 @@ _S_bit_shift_left(const _SimdTuple<_Tp, _As...>& __x, int __y) } template - static inline constexpr _SimdTuple<_Tp, _As...> + _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdTuple<_Tp, _As...> _S_bit_shift_right(const _SimdTuple<_Tp, _As...>& __x, int __y) { return __x._M_apply_per_chunk( @@ -1665,10 +1666,9 @@ _S_bit_shift_right(const _SimdTuple<_Tp, _As...>& __x, int __y) #undef _GLIBCXX_SIMD_APPLY_ON_TUPLE template - static _SimdTuple<_Tp, _Abis...> _S_remquo( - const _SimdTuple<_Tp, _Abis...>& __x, - const _SimdTuple<_Tp, _Abis...>& __y, - __fixed_size_storage_t::_S_size()>* __z) + static inline _SimdTuple<_Tp, _Abis...> + _S_remquo(const _SimdTuple<_Tp, _Abis...>& __x, const _SimdTuple<_Tp, _Abis...>& __y, + __fixed_size_storage_t::_S_size()>* __z) { return __x._M_apply_per_chunk( [](auto __impl, const auto __xx, const auto __yy, auto& __zz) @@ -1689,14 +1689,14 @@ _S_frexp(const _SimdTuple<_Tp, _As...>& __x, }, __exp); } -#define _GLIBCXX_SIMD_TEST_ON_TUPLE_(name_) \ - template \ - static inline _MaskMember \ - _S_##name_(const _SimdTuple<_Tp, _As...>& __x) noexcept \ - { \ - return _M_test([](auto __impl, \ - auto __xx) { return __impl._S_##name_(__xx); }, \ - __x); \ +#define _GLIBCXX_SIMD_TEST_ON_TUPLE_(name_) \ + template \ + static inline _MaskMember \ + _S_##name_(const _SimdTuple<_Tp, _As...>& __x) noexcept \ + { \ + return _M_test([] (auto __impl, auto __xx) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { \ + return __impl._S_##name_(__xx); \ + }, __x); \ } _GLIBCXX_SIMD_TEST_ON_TUPLE_(isinf)