This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Removing useless/redundant "const" calls
- From: law at redhat dot com
- To: Jason Merrill <jason at redhat dot com>
- Cc: Michael Matz <matz at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Jun 2003 11:57:42 -0600
- Subject: Re: [tree-ssa] Removing useless/redundant "const" calls
- Reply-to: law at redhat dot com
In message <wvlbrx3en88.fsf@prospero.boston.redhat.com>, Jason Merrill writes:
>On Thu, 12 Jun 2003 01:31:20 -0600, law@redhat.com wrote:
>
>> In message <Pine.LNX.4.44.0306120921320.4105-100000@wotan.suse.de>, Michael
> Mat
>> z writes:
>> >Hi,
>> >
>> >On Thu, 12 Jun 2003 law@redhat.com wrote:
>> >> 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.
>> >
>> >I see. But I guess this can be done?
>> Certainly. It wouldn't be terribly hard. First we clear TREE_SIDE_EFFECTS
>> for "pure" functions. Then we change this code in tree-ssa.c:
>>
>> /* Step 2. Check for redundant computations. Do this optimization only
>> for assignments that make no calls and have no aliased stores
>> nor volatile references and no side effects (i.e., no VDEFs). */
>> may_optimize_p = !ann->makes_aliased_stores
>> && !ann->has_volatile_ops
>> && vdefs == NULL
>> && def_p
>> && ! TREE_SIDE_EFFECTS (TREE_OPERAND (stmt, 1));
>>
>
>> to reject 'pure' functions.
>
>Seems to me the right way to model this would be to give the call a VUSE of
>global memory (and the targets of any pointer ops). Calls to pure
>functions can still be made redundant so long as there isn't an aliasing
>store between them.
>
>Calls to normal functions would then also have a VDEF of memory.
Ick. I'm definitely tabling optimizing pure calls for now. The problem
is that we set has_volatile_ops to nonzero if we try to register a use of
GLOBAL_VAR on the pure call. Once we've set has_volatile_ops to nonzero
it's all downhill.
This should be revisited when we do something sensible with objects in
static storage.
jeff