From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 6639B3853835; Thu, 24 Jun 2021 13:34:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6639B3853835 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-1782] libstdc++: Improve simd fixed_size codegen X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: ebb45cb816e3b808b29f05a934f6012a92d0c261 X-Git-Newrev: 343f01f4cde17003b6721722361e190bd6cffd15 Message-Id: <20210624133423.6639B3853835@sourceware.org> Date: Thu, 24 Jun 2021 13:34:23 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 13:34:23 -0000 https://gcc.gnu.org/g:343f01f4cde17003b6721722361e190bd6cffd15 commit r12-1782-g343f01f4cde17003b6721722361e190bd6cffd15 Author: Matthias Kretz Date: Thu Jun 24 14:20:14 2021 +0100 libstdc++: Improve simd fixed_size codegen Sometimes fixed_size objects will get unnecessarily copied on the stack. The simd implementation should never pass _SimdTuple by value to avoid requiring the optimizer to see through these copies. Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: * include/experimental/bits/simd_converter.h (_SimdConverter::operator()): Pass _SimdTuple by const-ref. * include/experimental/bits/simd_fixed_size.h (_GLIBCXX_SIMD_FIXED_OP): Pass binary operator _SimdTuple arguments by const-ref. (_S_masked_unary): Pass _SimdTuple by const-ref. Diff: --- libstdc++-v3/include/experimental/bits/simd_converter.h | 2 +- libstdc++-v3/include/experimental/bits/simd_fixed_size.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/experimental/bits/simd_converter.h b/libstdc++-v3/include/experimental/bits/simd_converter.h index 9c8bf382df9..11999df25e4 100644 --- a/libstdc++-v3/include/experimental/bits/simd_converter.h +++ b/libstdc++-v3/include/experimental/bits/simd_converter.h @@ -316,7 +316,7 @@ template _GLIBCXX_SIMD_INTRINSIC constexpr typename _SimdTraits<_To, _Ap>::_SimdMember - operator()(_Arg __x) const noexcept + operator()(const _Arg& __x) const noexcept { if constexpr (_Arg::_S_tuple_size == 1) return __vector_convert<__vector_type_t<_To, _Np>>(__x.first); diff --git a/libstdc++-v3/include/experimental/bits/simd_fixed_size.h b/libstdc++-v3/include/experimental/bits/simd_fixed_size.h index b6fb47cdf39..dc2fb90b9b2 100644 --- a/libstdc++-v3/include/experimental/bits/simd_fixed_size.h +++ b/libstdc++-v3/include/experimental/bits/simd_fixed_size.h @@ -1480,7 +1480,7 @@ template #define _GLIBCXX_SIMD_FIXED_OP(name_, op_) \ template \ static inline constexpr _SimdTuple<_Tp, _As...> name_( \ - const _SimdTuple<_Tp, _As...> __x, const _SimdTuple<_Tp, _As...> __y) \ + const _SimdTuple<_Tp, _As...>& __x, const _SimdTuple<_Tp, _As...>& __y)\ { \ return __x._M_apply_per_chunk( \ [](auto __impl, auto __xx, auto __yy) constexpr { \ @@ -1780,8 +1780,7 @@ template // _S_masked_unary {{{2 template