public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45221]  New: missed optimization on casting pointers even under -O3
@ 2010-08-07  1:28 navin dot kumar at gmail dot com
  2010-08-07 10:37 ` [Bug c++/45221] missed optimization with multiple bases and casting rguenth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: navin dot kumar at gmail dot com @ 2010-08-07  1:28 UTC (permalink / raw)
  To: gcc-bugs

Even under -O3, the assembly generated for foo1 and foo2 is vastly inferior to
the one generated for foo3, even though code-wise all three are identical.


class Base1 { int data; };
class Base2 { int data; };
class Derived : public Base1, public Base2 { public: int data; };

int foo1(Base2* x) {
    return static_cast<Derived&>(*x).data;
}

int foo2(Base2* x) {
    return static_cast<Derived*>(x)->data;
}

int foo3(Base2* x) {
    Base2& y = *x;
    return static_cast<Derived&>(y).data;
}


-- 
           Summary: missed optimization on casting pointers even under -O3
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: navin dot kumar at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-06 18:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-45221-4@http.gcc.gnu.org/bugzilla/>
2011-05-17 15:49 ` [Bug c++/45221] missed optimization with multiple bases and casting navin.kumar at gmail dot com
2023-05-06 18:14 ` pinskia at gcc dot gnu.org
2010-08-07  1:28 [Bug c++/45221] New: missed optimization on casting pointers even under -O3 navin dot kumar at gmail dot com
2010-08-07 10:37 ` [Bug c++/45221] missed optimization with multiple bases and casting rguenth at gcc dot gnu dot org
2010-08-07 15:26 ` navin dot kumar at gmail dot com
2010-08-07 16:19 ` rguenth at gcc dot gnu dot org
2010-08-07 16:23 ` navin dot kumar at gmail dot com
2010-08-07 16:25 ` rguenth at gcc dot gnu dot org
2010-08-07 16:27 ` rguenth at gcc dot gnu dot org
2010-08-07 17:28 ` navin dot kumar at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).