Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!burl!codas!ki4pv!tanner From: tanner@ki4pv.UUCP Newsgroups: comp.lang.c Subject: Questionable Optimizations Message-ID: <6943@ki4pv.UUCP> Date: Wed, 1-Apr-87 22:10:58 EST Article-I.D.: ki4pv.6943 Posted: Wed Apr 1 22:10:58 1987 Date-Received: Sat, 4-Apr-87 11:51:13 EST Organization: CompuData South, DeLand Lines: 35 Summary: user says how much he's willing to risk We have reason to be suspicious of re-writing constructs such as ((x*4) - 69) * 12 ==> (x*48) - (69*12) The fear is that we could introduce overflows for some values of x, 4, 69, and 12. This is a reasonable fear. One proposed solution is to forbid such things altogether. Lousy, slow code -- especially from macros. The other is to allow them, and have some unwary sucker come complaining that his prog is giving him an APR trap or the local equiv. It seems to me that we might want to consider explicitly specifying that under some circumstances, conforming compilers might be able to do these things, under user control. A compiler could claim to support some (including improper) subset of the following OPT levels: 0 = don't do any opts; writes lousy code 1 = clean up code; don't do questionable re-writes 2 = do anything it can think of A fair warning would be given: anyone using level 2 had better be sure of himself. Any compiler is free to neglect to supply any of the levels, but must specify which it does support. Any programmer who writes and immediately compiles level 2 deserves what he gets. Thus, the person who knows best what can safely be done (me: the guy using the damned conforming compiler) gets to say what can be done to my code. The reasons for using level 0 instead of 1: it takes longer to compile level 1 and we're still in the debugging phase; vendor only gives levels {0,2} and we don't trust 2. (What do you mean, this reminds you of a certain ALGOL compiler? Oh, \fBthat\fR algol compiler. Right.) -- {akgua!codas allegra decvax!ucf-cs ihnp4!hropus}!ki4pv!tanner