From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7A0B03898534; Mon, 16 Aug 2021 07:18:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A0B03898534 From: "dartdart26 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/101923] std::function's move ctor is slower than the copy one for empty source objects Date: Mon, 16 Aug 2021 07:18:12 +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: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dartdart26 at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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: 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: Mon, 16 Aug 2021 07:18:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101923 --- Comment #3 from Petar Ivanov --- Thank you for pointing the output on x86! Following that, I checked O2 and O3 on ARM64 and I see differences, though I cannot say what their actual impact is: 02: https://godbolt.org/z/P9Garznef O3: https://godbolt.org/z/Yb1q33YP3 In terms of x86, I ran the benchmark in Quick Bench (I assume x86 as that w= hat the disassembly is) and the results are similar to my findings on ARM64 - m= ove being slower: https://quick-bench.com/q/vK9eSYngutKGo4QSPcdra9gUOI0 The benchmark code seems correct to me, but I might be missing something, m= ight be misusing DoNotOptimize() or there might be some side effects. I am sure this is not a big deal. I was just wondering if adding an if statement is doable and, if yes, it seems like a quick and easy win.=