This is the mail archive of the gcc@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]

Re: oopack performance


Joe Buck <jbuck@synopsys.com> writes:

  > On Tue, May 06, 2003 at 06:28:54AM -0700, Dan Nicolaescu wrote:
  > > Mainline GCC performs well for the 3 of the 4 oopack benchmarks. 
  > > The only exception is "Complex". 
  > > ...
  > 
  > > The performance can be improved dramatically by just adding a
  > > constructor to the "Complex" class:
  > > 
  > > Complex (const Complex &F) : re(F.re), im(F.im) {}
  > 
  > This is very odd, because that's pretty much the same as the
  > default compiler-generated constructor.  Anyone have any idea
  > why there's so much difference?

Something is strange about the compiler generated constructor.

Given:

class Complex {
public:
    int re, im;
    Complex( int r, int i ) : re(r), im(i) {}
#ifdef MYCONSTRUCTOR
    Complex( const Complex & F ) : re(F.re), im(F.im) {}
#endif
    Complex() {}
};

Complex Yy;

void oop_style()
{
  Complex factor (53, 37);
  Yy = factor;
}

The oop_style function is compiled to: 

_Z9oop_stylev:
.LFB11:
        subl    $12, %esp       #,
.LCFI0:
        movl    $53, (%esp)     #,
        movl    (%esp), %edx    #, tmp64
        movl    $37, 4(%esp)    #, <variable>.im
        movl    4(%esp), %ecx   #,
        movl    %edx, Yy        # tmp64,
        movl    %ecx, Yy+4      #,
        addl    $12, %esp       #,
        ret

when using g++ -O3   -fverbose-asm -fomit-frame-pointer

and to:

_Z9oop_stylev:
.LFB14:
        subl    $28, %esp       #,
.LCFI0:
        movl    $53, %eax       #,
        movl    $37, %edx       #,
        movl    %eax, Yy        #,
        movl    %edx, Yy+4      #,
        addl    $28, %esp       #,
        ret


when using g++ -O3 -DMYCONSTRUCTOR  -fverbose-asm -fomit-frame-pointer

Node the extra move to the stack when using the compiler generated
constructor. 
Maybe this will help somebody figure what is going on.


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