From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21267 invoked by alias); 17 May 2011 15:41:56 -0000 Received: (qmail 21255 invoked by uid 22791); 17 May 2011 15:41:55 -0000 X-SWARE-Spam-Status: No, hits=-2.7 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; Tue, 17 May 2011 15:41:41 +0000 From: "navin.kumar at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/45221] missed optimization with multiple bases and casting X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: navin.kumar at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Version 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 Date: Tue, 17 May 2011 15:49:00 -0000 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: 2011-05/txt/msg01360.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221 Navin Kumar changed: What |Removed |Added ---------------------------------------------------------------------------- Version|4.5.0 |4.6.0 --- Comment #11 from Navin Kumar 2011-05-17 15:18:06 UTC --- Bumping this to 4.6.0 since the problem still exists. As a review (since this has been open and not updated for a while), the problem is very slow performance when dealing with C++'s multiple-inheritance (even under -O3). In the example below, the 'simple' fooA function generates slow code, whereas the equivalent code written with more steps in fooB generates optimal code. Base2* fooA(Derived* x) { Base2& y = *x; return &y; } Base2* fooB(Derived* x) { Derived& x2 = *x; Base2& y = x2; return &y; } Both fooA and fooB are funtionally identical. Yet the assembly generated for fooA is: leaq 4(%rdi), %rdx xorl %eax, %eax testq %rdi, %rdi cmovne %rdx, %rax ret and the assembly generated for fooB is: leaq 4(%rdi), %rax ret