public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@physics.uc.edu>
To: gcc-bugzilla@gcc.gnu.org
Cc: gcc-bugs@gcc.gnu.org
Subject: Re: [Bug libstdc++/23425] New: vector::clear should be manually inlined
Date: Tue, 16 Aug 2005 18:44:00 -0000	[thread overview]
Message-ID: <200508161843.j7GIhlv3003414@earth.phy.uc.edu> (raw)
In-Reply-To: <20050816182420.23425.tkho@ucla.edu>

> 
> vector::clear calls erase(begin(), end()), which has an unnecessary call to
> memmove, in addition to a function call overhead. The fix results in a
> 2-instruction clear for simple types.
> 
> Compiling the following (-O2 -save-temps) shows the difference:
> 
> #include <vector>
> 
> using std::vector;
> 
> int main() {
>   vector<int> v;
> 
>   asm("#start1");
>   v.clear();
>   asm("#end1");
> 
>   asm("#start2");
>   v.erase(v.begin(), v.end());
>   asm("#end2");
> }

as I mentioned on IRC, just marking erase as inline or figuring out why erase is not being inlined into clear
will fix this issue.  To the point where we have an empty loop which is removed with -funsafe-loop-optimizations
and a couple extra instructions which should be fixed with the tree combiner (but that is for 4.2 and not for
4.1).

-- Pinski


  parent reply	other threads:[~2005-08-16 18:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-16 18:26 tkho at ucla dot edu
2005-08-16 18:32 ` [Bug libstdc++/23425] " tkho at ucla dot edu
2005-08-16 18:44 ` Andrew Pinski [this message]
2005-08-16 18:46 ` pinskia at physics dot uc dot edu
2005-08-16 20:26 ` fang at csl dot cornell dot edu
2005-08-17  2:26 ` pinskia at gcc dot gnu dot org
2005-08-18  7:26 ` phython at gcc dot gnu dot 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=200508161843.j7GIhlv3003414@earth.phy.uc.edu \
    --to=pinskia@physics.uc.edu \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-bugzilla@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).