This is the mail archive of the
mailing list for the GCC project.
Re: [tree-ssa] Removing useless/redundant "const" calls
- From: law at redhat dot com
- To: Michael Matz <matz at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Jun 2003 00:54:08 -0600
- Subject: Re: [tree-ssa] Removing useless/redundant "const" calls
- Reply-to: law at redhat dot com
In message <Pine.LNX.email@example.com>, Michael Mat
>On Wed, 11 Jun 2003 firstname.lastname@example.org wrote:
>> This is the final patch needed to allow the compiler to remove
>> useless or redundant calls to "const" functions. It fixes
>There is no reason to not also remove useless calls to "pure" functions.
>They too have by definition no side-effects. Sure, they can read global
>memory (and hence proving "redundant" is harder), but this isn't a
>side-effect in the sense that it prevents removal. So, shouldn't
>TREE_SIDE_EFFECTS also be cleared for pure functions?
I couldn't convince myself that was actually safe. Possibly because
I haven't looked deeply into "pure" functions.
Given two invocations of a pure function with the same inputs, will the
pure function always return the same value? If the answer is no, then
we'll need to distinguish between pure and const functions later --
simply clearing TREE_SIDE_EFFECTS would result in incorrect code.
Is a pure function allowed to read volatile memory?