Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!microsoft!w-colinp From: w-colinp@microsoft.UUCP (Colin Plumb) Newsgroups: comp.lang.c Subject: Re: C optimizer Message-ID: <667@microsoft.UUCP> Date: 16 Feb 89 00:37:31 GMT References: <515@larry.UUCP> <9648@smoke.BRL.MIL> <13134@steinmetz.ge.com> <11767@haddock.ima.isc.com> Reply-To: w-colinp@microsoft.uucp (Colin Plumb) Organization: very little Lines: 33 karl@haddock.ima.isc.com (Karl Heuer) wrote: > 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. > > If the concept is to be useful, it had better mean "no observable side effects > AT ALL". > This is automatic if the "magic" is embedded in the standard > header files, via a keyword. Um... Karl, what strange disease has come over your brain to make it suddenly like adding keywords to C? :-) This is a perfect example of a good use for #pragma. In , I could just include: #pragma functional double sin(double), cos(double); And the compiler could take that as a hint to use common subexpression elimination (a pretty common optimisation) on sin and cos. A good compiler already knows that things like + and ~ are purely functional, and need only generalise the common subexpression and dead-code eliminators to handle more conventional function calls. This is also an example of the point of having a compiler ignore an unrecognised #pragma. Without this #pragma, the code would compute the same result, just more wastefully. -- -Colin (uunet!microsoft!w-colinp) "Don't listen to me. I never do."