This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/23425] vector::clear should be manually inlined
- From: "pinskia at physics dot uc dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Aug 2005 18:44:16 -0000
- Subject: [Bug libstdc++/23425] vector::clear should be manually inlined
- References: <20050816182420.23425.tkho@ucla.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at physics dot uc dot edu 2005-08-16 18:44 -------
Subject: Re: New: vector::clear should be manually inlined
>
> 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
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23425