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: Michael Matz <matz at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Jun 2003 01:31:20 -0600
- Subject: Re: [tree-ssa] Removing useless/redundant "const" calls
- Reply-to: law at redhat dot com
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.
Then you have DCE not consider pure or const functions are inherently
necessary.
I'm not currently planning to do this (I've been down in this rathole too
long), but I'm more than happy to help walk you through it.
jeff