From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey A Law To: Paul Derbyshire Cc: egcs@egcs.cygnus.com Subject: Re: Code gen question Date: Sun, 28 Feb 1999 22:53:00 -0000 Message-ID: <10117.918869905@hurl.cygnus.com> References: <3.0.6.32.19990212203311.0083e6d0@pop.netaddress.com> X-SW-Source: 1999-02n/msg00481.html Message-ID: <19990228225300.60Ek0JG_vLkeKjxkk6sUGp6Hn8eYT8isO7CGyLjykQY@z> In message < 3.0.6.32.19990212203311.0083e6d0@pop.netaddress.com >you write: > It won't? So it will observe that j is never modified making copying > unnecessary? The copy will initially appear, then be optimized away if at all possible by local and global copy propagation. > >The difference is that the latter refers to its > >arguments address, which impairs optimization (though not as much as it > >used to). > > It does? If the address isn't used except to dereference, I'd expect the > compiler to turn It will try, but it may not always succeed. When you take the address of an object you generally make analysis more difficult on the compiler and sometimes it will be unable to decipher the result. In general you are better off writing the code in the most natural and straightforward way instead of trying to micro-optimize too much. Instead spend your time writing goot algorithms. > >Absolutely pass scalars by value. > > Does this also apply to stock GCC? PGCC? Most of the differences among > these three gccs, except for namespace support (and extern inline behavior > :-)), are optimization differences. Yes. This generally applies to any compiler. As a general rule compilers are a lot better at optimizing scalars than pointers to scalars. jeff