public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amonakov at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-108487-4-Jsh8YtPOOW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108487-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108487

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |libstdc++

--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
libstdc++ uses a less efficient specialization of _M_range_initialize.

With 10.2 headers, we use

      template<typename _ForwardIterator>
 void
 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
       std::forward_iterator_tag)
 {
   const size_type __n = std::distance(__first, __last);
   this->_M_impl._M_start
     = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
   this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
   this->_M_impl._M_finish =
     std::__uninitialized_copy_a(__first, __last,
     this->_M_impl._M_start,
     _M_get_Tp_allocator());
 }

but with 10.4 headers, we use

      template<typename _InputIterator>
 void
 _M_range_initialize(_InputIterator __first, _InputIterator __last,
       std::input_iterator_tag)
 {
   try {
     for (; __first != __last; ++__first)

       emplace_back(*__first);

   } catch(...) {
     clear();
     throw;
   }
 }

  parent reply	other threads:[~2023-01-21 15:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 22:20 [Bug rtl-optimization/108487] New: " Mark_B53 at yahoo dot com
2023-01-21 11:48 ` [Bug tree-optimization/108487] [10/11/12/13 Regression] " amonakov at gcc dot gnu.org
2023-01-21 13:32 ` Mark_B53 at yahoo dot com
2023-01-21 15:38 ` amonakov at gcc dot gnu.org [this message]
2023-01-21 23:45 ` [Bug libstdc++/108487] " redi at gcc dot gnu.org
2023-01-21 23:50 ` redi at gcc dot gnu.org
2023-01-21 23:50 ` redi at gcc dot gnu.org
2023-01-22  3:07 ` Mark_B53 at yahoo dot com
2023-01-22 10:33 ` Mark_B53 at yahoo dot com
2023-01-22 17:14 ` redi at gcc dot gnu.org
2023-01-23  7:45 ` rguenth at gcc dot gnu.org
2023-03-27 11:03 ` rguenth at gcc dot gnu.org
2023-07-07 10:44 ` [Bug libstdc++/108487] [11/12/13/14 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108487-4-Jsh8YtPOOW@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).