Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!pyramid!amdcad!tim From: tim@amdcad.AMD.COM (Tim Olson) Newsgroups: comp.unix.questions Subject: Re: Wierd Compilers Message-ID: <18998@amdcad.AMD.COM> Date: Wed, 4-Nov-87 11:59:51 EST Article-I.D.: amdcad.18998 Posted: Wed Nov 4 11:59:51 1987 Date-Received: Sat, 7-Nov-87 10:17:19 EST References: <367@white.gcm> <18964@amdcad.AMD.COM> <44177@beno.seismo.CSS.GOV> Reply-To: tim@amdcad.UUCP (Tim Olson) Organization: Advanced Micro Devices Lines: 25 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. If a compiler made this "optimization" in the original programs to which this discussion is referring, it would be wrong. The return value of the decrement operators *is* used, by the while statement. #1: count = 5000; while (--count); /* executes 4999 loops */ #2: count = 5000; while (count--); /* executes 5000 loops */ -- Tim Olson Advanced Micro Devices (tim@amdcad.amd.com)