From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BE15385840B; Thu, 10 Mar 2022 23:04:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BE15385840B From: "jason at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/104719] Use of `std::move` in libstdc++ leads to worsened debug performance Date: Thu, 10 Mar 2022 23:04:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jason at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2022 23:04:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104719 Jason Merrill changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #12 from Jason Merrill --- (In reply to Vittorio Romeo from comment #9) > - For the `operator[]` benchmark, when using `-Og` after applying > `[[gnu::always_inline]]` to all the functions touched by the benchmark, we > reduce the overhead from 34% to around 11%.=20 Quoting from your gist: -Og, without `[[gnu::always_inline]]` on `operator[]` carray_squareop_mean 440 ns 439 ns 3 vector_squareop_mean 661 ns 662 ns 3 -Og, with `[[gnu::always_inline]]` on `operator[]` vector_squareop_mean 494 ns 491 ns 3 Which looks significant... ...but I don't see this when I run your test myself; the vector_squareop results (and the generated code) are unaffected by adding always_inline. In particular there are no calls to operator[]. carray_squareop 547 ns 546 ns 1272023 vector_squareop 591 ns 589 ns 1227215 carray: movslq %edx, %rax leaq (%rbx,%rax,4), %rcx movl (%rcx), %eax addl $1, %eax movl %eax, (%rcx) movl %eax, (%rcx) addl $1, %edx vector: movslq %ecx, %rax salq $2, %rax addq (%rsp), %rax movl (%rax), %esi leal 1(%rsi), %edx movl %edx, (%rax) movl %edx, (%rax) addl $1, %ecx It seems the main difference between the two is that the vector version nee= ds to keep loading the base pointer from the stack (%rsp) for some reason, rat= her than keep it in a register %rbx. This doesn't seem like an inlining issue = at all. The double move in both versions is curious.=