From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BDD63858D32; Sat, 21 Jan 2023 15:38:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BDD63858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674315512; bh=1dInjDduQOru53l+gffjOW+5lxR7k19cqXYx464KX+A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZJwuoArjVBi68PmizwY4Y0jreJv5BIuG1ETTgEgIaCxsFea41Ne/XDBABOlwji0dn PxNAErpOkakDVBV1tkV3eBZkdFPwnjcMQfD/5yRohymUvyBC4Ru23XRE5yTl/kv8JM 1H1pOXlHsl4Vowqr10DX47HWdIkSzQC+wiVKEDic= From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108487] [10/11/12/13 Regression] ~20-30x slowdown in populating std::vector from std::ranges::iota_view Date: Sat, 21 Jan 2023 15:38:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108487 Alexander Monakov changed: What |Removed |Added ---------------------------------------------------------------------------- Component|tree-optimization |libstdc++ --- Comment #3 from Alexander Monakov --- libstdc++ uses a less efficient specialization of _M_range_initialize. With 10.2 headers, we use template void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) { const size_type __n =3D std::distance(__first, __last); this->_M_impl._M_start =3D this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator())); this->_M_impl._M_end_of_storage =3D this->_M_impl._M_start + __n; this->_M_impl._M_finish =3D std::__uninitialized_copy_a(__first, __last, this->_M_impl._M_start, _M_get_Tp_allocator()); } but with 10.4 headers, we use template void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { try { for (; __first !=3D __last; ++__first) emplace_back(*__first); } catch(...) { clear(); throw; } }=