This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimisation question
- From: "Remy X.O. Martin" <vsxo at hotmail dot com>
- To: Joe Buck <Joe dot Buck at synopsys dot COM>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 1 Feb 2005 18:21:10 +0100
- Subject: Re: optimisation question
- References: <20050131152659.0dc92d6c@portia.local><41FE6ADB.3070706@adacore.com><20050131234317.GA4737@synopsys.com>
On Mon, 31 Jan 2005 15:43:17 -0800, Joe Buck <Joe.Buck@synopsys.COM> wrote regarding "Re:
optimisation question"
8-) > >a=b=c can be better than a=c; b=c; because the compiler could more easily
8-) > >use values in registers.
8-) >
8-) > That's nonsense for any reasonable compiler.
8-)
8-) Ah, but 15 years ago many compilers were not reasonable, and people were
8-) taught such things. Around that time period, extremely stupid register
8-) allocators were common, especially compilers designed to work in the
I can't remember if I actually ever tested which version was faster during those days. I was learning on the job (student's project, using an Atari ST and I can't recall what compiler -- Watson?).
I think, though, that the construct a=b=c exists by the very nature that it *could* be more efficient than the split-up version. It is not particularly more readable, for instance.
Here's another 'trick' I learned in those days: use a=b, c=d, e=f; rather than a=b; c=d; e=f; (like in the initialisation expression of a for loop). "The first version might be executed in parallel. Of course we don't have parellel machines here, but you never know..." I still use this syntax from time to time, but more for semantic reasons than anything else. Though, one indeed never knows :)
R.