http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58437
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> --- I can't reproduce this. I tried compiling with -O3 (with 4.4, 4.7 and 4.8) after commenting out either of the 2 sort lines, and I see roughly the same execution times (maybe a few % difference, but nowhere near the factor 6 you mention, which seems quite suspicious to me). You need to at least describe your platform more in details...