[tree-ssa] Removing useless/redundant "const" calls

Jason Merrill jason@redhat.com
Thu Jun 12 08:05:00 GMT 2003


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.

Jason



More information about the Gcc-patches mailing list