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]

Re: Code gen question


>>>>> Paul Derbyshire <pderbysh@usa.net> writes:

 > Which will cause cc1plus to generate better code?
 > inline int myclass::myfunc (int j) { return j*j*j; }

 > inline int myclass::myfunc (const int &j) { return j*j*j; }

 > My guess would be the latter, since the latter when inlined won't make a
 > copy of the argument passed.

Neither will the former.  The difference is that the latter refers to its
arguments address, which impairs optimization (though not as much as it
used to).  Absolutely pass scalars by value.

Jason


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