Path: utzoo!utgpu!watmath!clyde!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: C optimizer Keywords: C pure function optimization Message-ID: <11767@haddock.ima.isc.com> Date: 14 Feb 89 21:46:56 GMT References: <515@larry.UUCP> <9648@smoke.BRL.MIL> <13134@steinmetz.ge.com> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 24 In article <13134@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes: >One solution would be to provide a keyword ... which would indicate that a >procedure always returns the same value for a set of given arguments. Note >that this is not the same thing a "no side effects," my intent is only that a >second call with the same arguments would not change the side effects (such >as saving one of the arguments, etc). If the concept is to be useful, it had better mean "no observable side effects AT ALL". The (IMHO) useful optimization of extern int __pure abs(); x = abs(t); y = abs(u); z = abs(t); return (z-x); into return (0); seems to be forbidden by your weaker form. >I am not sure that having the compiler "know about" library functions is a >good idea, since the user could provide functions with identical names if the >compile were to be used in a non-hosted application. No problem; such a compiler, when used in freestanding mode, simply disables such knowledge. This is automatic if the "magic" is embedded in the standard header files, via a keyword. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint