a question about const and pure functions.

Geoffrey Keating geoffk@apple.com
Thu Nov 11 21:40:00 GMT 2004


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.)

-- 
Geoff Keating <geoffk@apple.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2408 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20041111/f375015c/attachment.p7s>


More information about the Gcc mailing list