This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimisation question
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Robert Dewar <dewar at adacore dot com>
- Cc: "Remy X.O. Martin" <vsxo at hotmail dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 31 Jan 2005 15:43:17 -0800
- Subject: Re: optimisation question
- References: <20050131152659.0dc92d6c@portia.local> <41FE6ADB.3070706@adacore.com>
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".