This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/33546] New: [missed optimization] trivial static function not inlined.


$ cat 0.cpp
template < typename R, typename T, R ( T::* method )() >
static inline R dispatch( T& object )
{
        return ( object.*method )();
}
struct X
{
        virtual ~X();
        virtual void f();
};
void test1( X& obj )
{
        void ( *f )( X& ) = dispatch< void, X, &X::f >;
        f( obj );
}
void test2( X& obj )
{
        obj.f();
}

g++-4.2.2-RC1 produces unoptimal code for test1:

test1(X&):
        jmp     void dispatch<void, X, &(X::f())>(X&)

test2(X&):
        movq    (%rdi), %rax
        movq    16(%rax), %r11
        jmp     *%r11

void dispatch<void, X, &(X::f())>(X&):
        movq    (%rdi), %rax
        movq    16(%rax), %r11
        jmp     *%r11


-- 
           Summary: [missed optimization] trivial static function not
                    inlined.
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net
GCC target triplet: x86_64-gnu-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]