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: pure and const functions


On Mon, 29 Apr 2002, Daniel Berlin wrote:

> > This seems nice and simple, but #2 confuses things.  As I understand it,
> > GCC automatically trys to prove functions pure.  Obviously it will not be
> > able to figure out the structure of a memoizing function in general, so it
> > would punt on these functions, thus not automatically marking it pure.
>
> This is not necessarily true.
> Some of the algorithms i've implemented or am experimenting with to
> compute MOD/REF and GMOD/GREF seem to do just fine on most memoizing
> functions.

While I'm sure that there is room for improvement in our analysis of pure
functions, the point was originally that there will always be cases that
are not analyzable (for example, the sqrt case mentioned by Robert, which
is NOT pure, but the programmer can decide to treat it as such).  The fact
that there are unanalyzable cases does not automatically make them not
"pure", they just aren't analyzable.

That said, it will be interesting to see how much benefit your analysis
provides to common programs... how many pure functions do you typically
find?  Are the GCC transformations able to take advantage of the extra
information to increase performance?

-Chris

http://www.nondot.org/~sabre/os/
http://www.nondot.org/~sabre/Projects/


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