public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100322] New: Switching from std=c++17 to std=c++20 causes performance regression in relationals
@ 2021-04-28 17:15 aaron at aarongraham dot com
  2021-04-28 17:49 ` [Bug c++/100322] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: aaron at aarongraham dot com @ 2021-04-28 17:15 UTC (permalink / raw)
  To: gcc-bugs

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)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-04-29  8:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 17:15 [Bug c++/100322] New: Switching from std=c++17 to std=c++20 causes performance regression in relationals aaron at aarongraham dot com
2021-04-28 17:49 ` [Bug c++/100322] " redi at gcc dot gnu.org
2021-04-28 18:03 ` redi at gcc dot gnu.org
2021-04-28 18:13 ` redi at gcc dot gnu.org
2021-04-28 18:18 ` barry.revzin at gmail dot com
2021-04-28 18:19 ` barry.revzin at gmail dot com
2021-04-28 18:20 ` redi at gcc dot gnu.org
2021-04-28 22:55 ` glisse at gcc dot gnu.org
2021-04-29  8:55 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).