Re: Unsafe Optimizations (formerly Compiler Design in C...)

pardo@june.cs.washington.edu (David Keppel)
Thu, 21 Jun 90 18:41:25 GMT

          From comp.compilers

Related articles
[9 earlier articles]
Re: Unsafe Optimizations (formerly Compiler Design in C...) barmar@Think.COM (1990-06-15)
Re: Unsafe Optimizations (formerly Compiler Design in C...) henry@zoo.toronto.edu (1990-06-20)
Re: Unsafe Optimizations (formerly Compiler Design in C...) dan@kfw.com (1990-06-20)
Re: Unsafe Optimizations (formerly Compiler Design in C...) chip@tct.uucp (1990-06-20)
Re: Unsafe Optimizations (formerly Compiler Design in C...) grunwald@foobar.Colorado.EDU (Dirk Grunwald) (1990-06-20)
Re: Unsafe Optimizations (formerly Compiler Design in C...) marti@inf.ethz.ch (1990-06-21)
Re: Unsafe Optimizations (formerly Compiler Design in C...) pardo@june.cs.washington.edu (1990-06-21)
Re: Unsafe Optimizations (formerly Compiler Design in C...) kend%mrloog.wr.tek.com@RELAY.CS.NET (Ken Dickey) (1990-06-21)
Re: Unsafe Optimizations (formerly Compiler Design in C...) chittamu@dino.cs.umass.edu (1990-06-22)
Re: Unsafe Optimizations (formerly Compiler Design in C...) harrison@necssd.NEC.COM (1990-06-23)
| List of all articles for this month |

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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.