C optimizer

William E. Davidsen Jr davidsen at steinmetz.ge.com
Wed Feb 15 01:14:56 AEST 1989


In article <9648 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:

| This is an interesting issue.  In traditional C implementations, since
| there was no guarantee that the functions wouldn't have side effects
	...

| ...						    ... a sufficiently
| clever optimizer could take advantage of the fact that they're known to
| be so-called "pure" functions to avoid calling them multiple times with
| the same argument.  I don't know of any implementations that perform
| this particular optimization, but I suspect the supercomputer folks
| will be doing it.

  I agree. One solution would be to provide a keyword, perhaps something
like 'pure' or 'deterministic', 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).

  There must be a good mathmatical term for this, 'pure' has too many
overloaded meanings, and 'deterministic' is far too long. 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.
-- 
	bill davidsen		(wedu at ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list