Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ll-xn!husc6!bbn!rochester!PT.CS.CMU.EDU!IUS1.CS.CMU.EDU!edw From: edw@IUS1.CS.CMU.EDU (Eddie Wyatt) Newsgroups: comp.unix.questions Subject: Re: Wierd Compilers Message-ID: <300@PT.CS.CMU.EDU> Date: Wed, 4-Nov-87 09:24:46 EST Article-I.D.: PT.300 Posted: Wed Nov 4 09:24:46 1987 Date-Received: Sat, 7-Nov-87 11:06:11 EST References: <367@white.gcm> <18964@amdcad.AMD.COM> <44177@beno.seismo.CSS.GOV> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 36 Keywords: Sun In article <44177@beno.seismo.CSS.GOV>, rick@seismo.CSS.GOV (Rick Adams) writes: > Even a mediocre compiler should be able to recognize that > a++; > is equivalent to > ++a; > if there is no assignment, etc. > > There is really no excuse for not making this trivial optimization. You should > not have to depend on the user doing it. > > --rick But they are not equivalent in the context they where used (refering back to the original article). i = 10 #1 while (i--) ; #2 while (--i) ; In number one the operation is executed 10 times. In number two the operation is executed 9 times. This is because the value of "--" applied to a var is not ignored. #2 can be made totally equivalent to #1 as follows: i++; while (--i) { /* my junk */ } Which is what I do. -- That one looks Jewish -- And that one's a coon -- Who let all this riff raff into the room -- There's one smoking a joint -- and Anoter with spots -- If I had my way -- I'd have all of you shot ... Pink Floyd, "In the Flesh" Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu