Related articles |
---|
Re: Optimizing Across && And || bart@cs.uoregon.edu (1995-02-23) |
Re: Safety and legality of optimizations cliffc@crocus.hpl.hp.com (1995-03-21) |
Re: Safety and legality of optimizations Vinod.Grover@Eng.Sun.COM (1995-03-28) |
Re: Safety and legality of optimizations cliffc@crocus.hpl.hp.com (1995-04-03) |
Re: Safety and legality of optimizations cef@geodesic.com (Charles Fiterman) (1995-04-15) |
Re: Safety and legality of optimizations Dave@OCCL-CAM.DEMON.CO.UK (Dave Lloyd) (1995-04-18) |
Re: Safety and legality of optimizations cliffc@crocus.hpl.hp.com (1995-04-17) |
Re: Safety and legality of optimizations jim@meiko.co.uk (1995-04-21) |
Re: Safety and legality of optimizations clodius@lanl.gov (1995-04-26) |
Newsgroups: | comp.compilers |
From: | cliffc@crocus.hpl.hp.com (Cliff Click) |
Keywords: | optimize |
Organization: | Hewlett-Packard Laboratories, Cambridge Research Office |
References: | 95-02-179 95-04-075 |
Date: | Mon, 17 Apr 1995 13:28:28 GMT |
Charles Fiterman <cef@geodesic.com> writes:
> How about a pure keyword. Pure means this is a pure function. It
> looks at its parameters and returns a value, it has no side effects.
> Calls to pure functions can be lifted out of loops or even done at
> compile time if the right things are known at compile time.
Pure would actually be fairly easy to add to a compiler.
Pure functions are more susceptible to optimizations.
Pure functions need to be compiled with some restrictions:
- only store to local variables (no writes to globals), and
- only call other pure functions.
Another useful keyword might be "only_mods_parms" - only modifies through
parameters or locals. This is a slightly less pure function that can
only modify what is passed by reference to it. A pure function can call
it with pointers to the pure's locals.
In general, making explicit the function domain enables the compiler.
This is especially true for separately compiled functions.
> Note a function that calls error is not strictly pure. Neither is
> a function that memoizes. Pure says this may be used as if it was
> pure. Being able to attach the word to impure functions is the
> best use of pure.
Like "casting away const", casting away pure is fraught with danger and
assumptions about current and future compiler technology. Fortran compilers
routinely know that intrinsics are pure, and at least 1 research compiler
looked at memoizing pure calls.
Cliff
--
Cliff Click Compiler Research Scientist
Cambridge Research Office, Hewlett-Packard Laboratories
One Main Street, 10th Floor, Cambridge, MA 02142
(617) 225-4915 Work (617) 225-4930 Fax
cliffc@hpl.hp.com http://bellona.cs.rice.edu/MSCP/cliff.html
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.