Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!columbia!rutgers!ucla-cs!cit-vax!elroy!jplgodo!wlbr!scgvaxd!ashtate!dbase!ghsvax!edk
From: edk@ghsvax.UUCP (Ed Kaulakis)
Newsgroups: comp.lang.c
Subject: Re: Style [++i vs i++]
Message-ID: <45@ghsvax.UUCP>
Date: Wed, 22-Jul-87 12:09:17 EDT
Article-I.D.: ghsvax.45
Posted: Wed Jul 22 12:09:17 1987
Date-Received: Sat, 25-Jul-87 11:44:28 EDT
References: <17310@amdcad.AMD.COM> <2159@emory.uucp> <43@ghsvax.UUCP> <5068@utcsri.UUCP>
Lines: 42
Summary: ok, some...

In article <5068@utcsri.UUCP>, greg@utcsri.UUCP writes:
> In article <795@nu3b2.UUCP> rwhite@nu3b2.UUCP (Robert C. White Jr.) writes:
> >In article <223@wrs.UUCP>, dg@wrs.UUCP (David Goodenough) writes:
> >> In article <43@ghsvax.UUCP> edk@ghsvax.UUCP (Ed Kaulakis) writes:
> >> >
> >> >	Many compilers will materialize the (returned old value) of i++ even 
> >> >when nobody wants it, but will do better with ++i.
> >> 
> >> Ye gads! what braindamaged piece of software are you using?? - I've worked
> >
> >	Pardon my foolish inquiry... isnt i++ SUPPOSED to return the old
> >value of i AND THEN increment it's stored value.  Ed, if this isnt what
> >you mean ignore this and then post an example of the misfunctioning code,
> >I for one would love to see a murdered code fragment and credits for the
> >complier. [as a warning against purchase]
> 
> The key is 'when nobody wants it'. And I wouldn't say "Many" compilers unless
> you use grotty micro compilers on a regular basis.
> 
> Example: Small-C, for 8080, and its progeny C/80 from Software Toolworks:
> 
[ interesting stuff deleted ]

Well, ok, some. I have seen this in a quite modern compiler which doesn't do
template matching but relies on register coloring and its associated dataflow
analysis, but (currently) has a null peephole optimizer. Now the problem here
is that code is generated before any dataflow analysis, and so the register
residency of the "returned" value is a fact of life for the register allocator,
thus x++ ==> x->tmp; ++x actually touches a tmp register; never mind that this
is eliminated by dead code later; it prevents something else living in this
register over the x++. One solution of course is to add some template matching
to the front end. Another interesting solution is to iterate codegen and 
allocate for a while... after all, linear programming is formally NP too, and
it works this year...

This compiler, brain-damaged at this stage of its life, consistently 
outperforms [pqr]cc derivatives.

And now... the envelope please...
the compiler in question is Kaulakis Enterprise's retargeting of the Green
Hills (VAX base) code generator to Gould. The null peephole and any other 
brain damage is ours, not Green Hills'.