This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45221] missed optimization with multiple bases and casting
- From: "navin.kumar at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 17 May 2011 15:41:41 +0000
- Subject: [Bug c++/45221] missed optimization with multiple bases and casting
- Auto-submitted: auto-generated
- References: <bug-45221-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221
Navin Kumar <navin.kumar at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|4.5.0 |4.6.0
--- Comment #11 from Navin Kumar <navin.kumar at gmail dot com> 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