http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51078
--- Comment #14 from Grygoriy Fuchedzhy <grygoriy.fuchedzhy at gmail dot com> 2011-11-12 10:09:52 UTC --- (In reply to comment #13) > I would say, the next step, is analyzing why: std::count seems a very simple > algorithm, no aliasing issues for example, compiler should be able to unroll, > maybe vectorize too, and everything else, without having to fiddle with the > code in an ad-hoc way. I completely agree that analizing why is necessary, but this probably should be done in separate bug?(should I open it?) As regarding current bug: it seems that automatic loop unrolling is far from being considered "stable" or "recommended" optimization, so this patch may improve performance until this optimization become commonly used. By the way, manually unrolled std::find, one of old algorithms you mentioned also performs significantly better than version without loop unrolling.