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: mainline performance regression (observered on SPARC)


"David S. Miller" <davem@redhat.com> writes:

  >    From: Dan Nicolaescu <dann@ics.uci.edu>
  >    Date: Fri, 24 May 2002 11:36:48 -0700
  >    
  >    The code is kind of silly, it moves stuff around between the integer
  >    and fp registers, probably an artifact of the SPARC calling
  >    conventions (passing doubles in the integer registers). But shouldn't
  >    inlining get rid of this? 
  >    
  > The functions are emitted, there are not inlined.  How can inlining
  > help this situation?  We have to follow the argument passing rules
  > as they are in this case.

Sorry, I wasn't very clear, I was refering to the Complex constructor,
the "+" and "*" overloaded operators and that _are_ inlined.

Please take a look at the (simplified) code below and compare what is
emitted for c_style and oop_style


class ComplexBenchmark {
private:
    void c_style() const; 
    void oop_style() const;
} TheComplexBenchmark;

class Complex {
public:
    double re, im;
    Complex( double r, double i ) : re(r), im(i) {}
    Complex() {}
};

inline Complex operator+( Complex a, Complex b )        // Complex add
{
    return Complex( a.re+b.re, a.im+b.im );
}

inline Complex operator*( Complex a, Complex b )        // Complex multiply
{
    return Complex( a.re*b.re-a.im*b.im, a.re*b.im+a.im*b.re );
}

Complex X[N], Y[N];                             // Arrays used by benchmark


void ComplexBenchmark::oop_style() const        // OOP-style complex-valued SAXP
Y operation 
{
    Complex factor( 0.5, 0.86602540378443864676 );
    for( int k=0; k<N; k++ )
        Y[k] = Y[k] + factor*X[k];
}

void ComplexBenchmark::c_style() const          // C-style complex-valued SAXPY 
operation
{
    double factor_re = 0.5;
    double factor_im = 0.86602540378443864676;
    for( int k=0; k<N; k++ ) {
        Y[k].re = Y[k].re + factor_re*X[k].re - factor_im*X[k].im;
        Y[k].im = Y[k].im + factor_re*X[k].im + factor_im*X[k].re;
    }
}


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