------- 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

Reply via email to