https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100322
Bug ID: 100322 Summary: Switching from std=c++17 to std=c++20 causes performance regression in relationals Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: aaron at aarongraham dot com Target Milestone: --- Experiment here: https://godbolt.org/z/PT73cn5e5 #include <chrono> using clk = std::chrono::steady_clock; bool compare_count(clk::duration a, clk::duration b) { return a.count() > b.count(); } bool compare(clk::duration a, clk::duration b) { return a > b; } Compiling with -std=c++17 I get: _Z13compare_countNSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEES3_: cmp r2, r0 sbcs r3, r3, r1 ite lt movlt r0, #1 movge r0, #0 bx lr _Z7compareNSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEES3_: cmp r2, r0 sbcs r3, r3, r1 ite lt movlt r0, #1 movge r0, #0 bx lr Compiling with -std=c++20 I get: _Z13compare_countNSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEES3_: cmp r2, r0 sbcs r3, r3, r1 ite lt movlt r0, #1 movge r0, #0 bx lr _Z7compareNSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEES3_: cmp r1, r3 it eq cmpeq r0, r2 beq .L4 cmp r0, r2 sbcs r3, r1, r3 bge .L5 mov r0, #-1 .L3: cmp r0, #0 ite le movle r0, #0 movgt r0, #1 bx lr .L4: movs r0, #0 b .L3 .L5: movs r0, #1 b .L3 (Note that clang doesn't have this problem)