This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: a question about const and pure functions.




Geoffrey Keating wrote:


On 11/11/2004, at 6:17 AM, Kenneth Zadeck wrote:


The extensions that I want to add are:

1) allow const to access memory if the memory is a constant, i.e. if you have a readonly static with a decl initial that satisfies is_gimple_min_invariant (), such a reference need not be treated differently than referencing a "5".

2) move the processing earlier so that it is available to the rest of the compiler.

3) allow for recursive and mutually recursive pure and const functions.

4) eventually to allow some loops (if they can be proven to be finite) rather than just looking for back edges in the cfg. We have this analysis in the compiler, we should be allowed to use the info here.

The hope here is that with the exception of setting errno, that most small table driven mathematical functions would fall into one of these categories.


All this sounds like a great idea.

(I would caution, though, that really you should check that a recursive function terminates. You may be able to finesse the issue on the grounds that a recursive function that doesn't terminate will usually eventually run out of stack and terminate that way.)

Yes, that was exactly my plan, even on a 64 bit machine, it will eventually terminate.

kenny


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]