[Bug target/93243] misoptimization: minor changes of the code leads change up to +/- 30% performance on x86_64, -Os faster than -Ofast/O2/O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93243 --- Comment #5 from Leo Yuriev --- Created attachment 47658 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47658&action=edit testcase makefile
[Bug target/93243] misoptimization: minor changes of the code leads change up to +/- 30% performance on x86_64, -Os faster than -Ofast/O2/O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93243 --- Comment #4 from Leo Yuriev --- Created attachment 47657 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47657&action=edit testcase source code
[Bug target/93243] misoptimization: minor changes of the code leads change up to +/- 30% performance on x86_64, -Os faster than -Ofast/O2/O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93243 --- Comment #3 from Leo Yuriev --- > (a) < (b) is not equal to ((a) - (b) < 0) > Compiler will trait them differently. Yes, of course. Moreover, in the second case, correct sorting requires limiting the range of keys to avoid overflow when comparing by subtraction. However, such changes in the code shouldn't cause such a significant performance change. Moreover, this can't be an excuse for generating slower code compared to clang. For clarity: - We look to the benchmark of heapsort, with random data, in the two cases: `small` and `large`. - GCC shown unexpected performance changes by minor code changes. - CLANG shown stable result and better perfomance than GCC's in all cases. - moreover, GCC shown better performance with -Os rather with -Ofast. So, seems this is a misoptimization bug.
[Bug target/93243] misoptimization: minor changes of the code leads change up to +/- 30% performance on x86_64, -Os faster than -Ofast/O2/O3
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93243 --- Comment #2 from Hongtao.liu --- > The diffs in the source code are: > #if CASE & 1 > #define CMP(a, b) ((a) < (b)) > #else > #define CMP(a, b) (((a) - (b)) < 0) > #endiF > (a) < (b) is not equal to ((a) - (b) < 0) Compiler will trait them differently.