From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30828 invoked by alias); 23 Jan 2012 23:19:04 -0000 Received: (qmail 30819 invoked by uid 22791); 23 Jan 2012 23:19:03 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 23:18:50 +0000 From: "marc.glisse at normalesup dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/51965] Redundant move constructions in heap algorithms Date: Mon, 23 Jan 2012 23:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: marc.glisse at normalesup dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg02716.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51965 Marc Glisse changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marc.glisse at normalesup | |dot org --- Comment #5 from Marc Glisse 2012-01-23 23:18:20 UTC --- (The split into push_heap and __push_heap is just so the first part can be inlined without the second, right?) A more direct adaptation of the old code to rvalue references would be: std::__push_heap(__first, _DistanceType((__last - __first) - 1), _DistanceType(0), _ValueType(_GLIBCXX_MOVE(*(__last - 1)))); Without the named temporary value, the compiler can perform copy elision. Aliaksandr's patch looks like a different way to achieve the same goal. Note that the current code thus seems to have a performance regression in C++03 compared to before the introduction of moves.