https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93521
Bug ID: 93521 Summary: 40% slower in O2 than O1 (tree-pre) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hehaochen at hotmail dot com Target Milestone: --- Created attachment 47747 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47747&action=edit testcase The attached heap sort is ~40% slower in O2 than O1 (slow with tree-pre) gcc-9 (Homebrew GCC 9.2.0_2) 9.2.0: g++-9 -O1 stepanov_vector.cpp -o a.out && ./a.out >> 7.48 sec g++-9 -O1 -ftree-pre stepanov_vector.cpp -o a.out && ./a.out >> 12.21 sec g++-9 -O2 stepanov_vector.cpp -o a.out && ./a.out >> 12.25 sec g++-9 -O2 -fno-inline-small-functions stepanov_vector.cpp -o a.out && ./a.out >> 10.72 sec g++-9 -O2 -fno-tree-pre stepanov_vector.cpp -o a.out && ./a.out >> 9.63 sec while in clang: Apple clang version 11.0.0 (clang-1100.0.33.17) clang++ -O1 stepanov_vector.cpp >> 38.04 sec clang++ -O2 stepanov_vector.cpp >> 4.85 sec