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: optimisation question


On Mon, Jan 31, 2005 at 12:28:59PM -0500, Robert Dewar wrote:
> Remy X.O. Martin wrote:
> 
> >As far as I remember, I have been taught (like 15 years ago) that writing 
> >a=b=c can be better than a=c; b=c; because the compiler could more easily 
> >use values in registers. 
> 
> That's nonsense for any reasonable compiler.

Ah, but 15 years ago many compilers were not reasonable, and people were
taught such things.  Around that time period, extremely stupid register
allocators were common, especially compilers designed to work in the
extremely constrained environment of 16-bit x86 code, and programmers of
that era learned all kinds of bad habits to work around their flaws.
Lots of old-time C programmers believe many things that haven't been
true for a decade.

Unless you've done profiling and determined that you have a critical inner
loop, it's best to optimize your code's form for readability and
maintainability, rather than to tweak it based on a belief you haven't
tested that compilers will "like it better".


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