Newsgroups: | comp.compilers |
From: | pardo@june.cs.washington.edu (David Keppel) |
References: | <1990Jun12.163959.2593@esegue.segue.boston.ma.us> <1990Jun13.143951.2129@esegue.segue.boston.ma.us> <1990Jun15.051349.3016@esegue.segue.boston.ma.us> <267CF0BD.5B1A@tct.uucp> |
Date: | Thu, 21 Jun 90 18:41:25 GMT |
Organization: | University of Washington, Computer Science, Seattle |
Keywords: | code, optimize |
I wrote recently about the implementation performance of strcpy via
while (*d++ = *s++)
;
vs.
while (d[i] = a[i])
++i
Several people have (rightly) pointed out that the second has three
adds where the former has only two. The point, again, is where your
'puter gives you your ``for free'' adds. If you get none, the first is
faster. If you get them in indexed addressing, the second is faster.
If you get them in auto-post-incrment addressing modes, the first is
faster. If you get them in `movc5', it is anybody's guess...
chip@tct.uucp (Chip Salzenberg) writes:
>And besides, completely *safe* optimizations can transform either form
>into the other. So there. :-)
Yeah, that was the point :-)
;-D oN (
--
pardo@cs.washington.edu
{rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.