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: two-element struct performance (was: strict-aliasing and typedefs)


Joe Buck <jbuck@synopsys.com> writes:

| On Thu, May 15, 2003 at 12:16:56AM +0200, Gabriel Dos Reis wrote:
| > Joe Buck <jbuck@synopsys.com> writes:
| > 
| > | GCC does a decent job with one-element structs; its performance
| > | quickly drops like a rock as soon as there are two elements.  Still,
| > | there may well be some loss from using it.
| > 
| > Would that loss of performance be related to ABI issues (in single
| > element case)? 
| 
| No, it has to do with premature commitment of structs to memory.

Aha, thanks.  I thought that since some ABIs seem to require that every
structure ought to be returned in memory, GCC (on those targets)
cannot optimize away the abstraction penatly in the case a structure
contains a single or two scalar(s). 

[...]

| Take a look, for example, at the code generated for the following:
| 
| --------------------------------
| struct complex {
|     double re, im;
|     complex(double r, double i) : re(r), im(i) {}
| };
| 
| inline complex operator+(const complex& a, const complex& b) {
|     return complex(a.re+b.re, a.im+b.im);
| }
| 
| complex addone(const complex& arg) {
|     return arg + complex(1,0);
| }

I believe we have a (old) bug report along that line.

[...]

| >From looking at the tree dumps on the tree-ssa branch, it would seem that a
| decent copy propagation pass could propagate the 1.0 and 0.0 values through,
| leaving the temporary struct as a dead object.

That is good news.

-- Gaby


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