This is the mail archive of the 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: [tree-ssa] Removing useless/redundant "const" calls

In message <>, Jason Merrill writes:
 >On Thu, 12 Jun 2003 01:31:20 -0600, wrote:
 >> In message <>, Michael
 > Mat
 >> z writes:
 >>  >Hi,
 >>  >
 >>  >On Thu, 12 Jun 2003 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.  


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