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, 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.


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