http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58437
Bug ID: 58437 Summary: Sorting value in reverse order is much slower compare to gcc44 Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tammy at Cadence dot COM For the following testcase: ======================================================= #include <algorithm> #include <vector> using namespace std; int main() { const size_t num = 10000000; vector<int> v(num); generate(v.begin(), v.end(), &rand); sort(v.begin(), v.end()); sort(v.rbegin(), v.rend()); } ====================================================== If we compile it with "g++ -O3", it takes 1 sec to sort random values with either gcc445 or gcc481. Gcc445 takes 0.33 sec to sort value in reverse order, but gcc 4.7/4.8 takes 2 secs. Is there any way to improve the run-time performance?