Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site cbosgd.UUCP Path: utzoo!watmath!clyde!cbosgd!ka From: ka@cbosgd.UUCP (Kenneth Almquist) Newsgroups: net.unix-wizards Subject: Re: Optimizing Compilers Message-ID: <690@cbosgd.UUCP> Date: Thu, 10-Jan-85 18:48:22 EST Article-I.D.: cbosgd.690 Posted: Thu Jan 10 18:48:22 1985 Date-Received: Sat, 12-Jan-85 01:41:09 EST References: <6886@brl-tgr.ARPA> Organization: Bell Labs, Columbus Lines: 18 > The point is where do you draw the line? Not > that an optimizer should NEVER change an effect. Normally, the rule is that an optimizing compiler should conform to the language standard. In C, for example, the order of evaluation of expressions is explicitly undefined in most cases. Thus an optimizer may reorder expressions to improve efficiency, even if this changes the behavior of the program. The case under discussion involved moving a division by zero out of a loop so that only 1 exception rather than 100 exceptions are generated. For many languages this would be OK because the effects of of a program that performs divisions by zero are left undefined. In the case of C, the situation is somewhat different because C is used for a variety of systems programming type jobs which require that the code generated by the compiler be unsurprising. The proposed ANSI standard for C makes this optimization invalid. Kenneth Almquist