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 gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Aug 2005 02:23:35 -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 gcc dot gnu dot org 2005-08-17 02:23 -------
Confirmed, there are two different issues here because it looks like the pool allocator injects code
which initializes a variable, even though there is a different way of doing the initialization. It should be
doing the say initialization as the cout/cin/cerr initializes its streams.
This causes us when we call erase:
if (*_ZGVZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE11_S_get_poolEvE7_S_pool.62 ==
0) goto <L12>; else goto <L2>;
<L12>:;
_S_pool.D.8154._M_options._M_align = 8;
_S_pool.D.8154._M_options._M_max_bytes = 128;
_S_pool.D.8154._M_options._M_min_bin = 8;
_S_pool.D.8154._M_options._M_chunk_size = 4080;
_S_pool.D.8154._M_options._M_max_threads = 4096;
_S_pool.D.8154._M_options._M_freelist_headroom = 10;
D.12526 = getenv (&"GLIBCXX_FORCE_NEW"[0]);
_S_pool.D.8154._M_options._M_force_new = D.12526 != 0B;
_S_pool.D.8154._M_binmap = 0B;
_S_pool.D.8154._M_init = 0;
_S_pool._M_bin = 0B;
_S_pool._M_bin_size = 1;
_S_pool._M_thread_freelist = 0B;
_S_pool._M_once = 0;
*_ZGVZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE11_S_get_poolEvE7_S_pool.62 = 1;
which blocks a lot of the other optimizations because there is a function call and there is always a
branch. This is not a problem on PPC-darwin where we don't have this "junk".
Second we don't inline erase into clear for some reason. I could not figure it out from the dumps
maybe someone else will be able to.
The rest is for the reporter really (and any one who is writting missed optimization bugs)
A better way of seeing the different is:
#include <vector>
std::vector<int> v;
void clear1() { v.clear(); }
void clear2(){ v.erase(v.begin(), v.end()); }
As using asm("#start1"); can be moved around and for your example at -O3, we actually get an empty
function as v is known to be unused.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
GCC host triplet|i686-unknown-linux-gnu |
GCC target triplet| |i686-*-linux-gnu
Keywords| |missed-optimization
Last reconfirmed|0000-00-00 00:00:00 |2005-08-17 02:23:28
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23425