This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [AST-optimizer-branch] Double chaining statements (proposal)
- From: Sebastian Pop <m1sp at csc dot liv dot ac dot uk>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Sebastian Pop <m1sp at csc dot liv dot ac dot uk>, nathan at codesourcery dot com, gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 23 Apr 2002 18:18:37 +0100
- Subject: Re: [AST-optimizer-branch] Double chaining statements (proposal)
- References: <20020415174644.A26739@linux18.lxfarm.csc.liv.ac.uk> <20020423142810.GB17059@tornado.toronto.redhat.com>
On Tue, Apr 23, 2002 at 10:28:10AM -0400, Diego Novillo wrote:
> At times I have wished I had a TREE_PREV() link, but I am not
> absolutely convinced that it is a requirement. We have several
> options:
>
> - Overloading an existing field. This saves memory but abuses
> the name space. We already have much name abusing in the tree
> structure.
>
Yes but we can keep this information only locally and once we don't need
it anymore just reset it to NULL as it was before.
> - Creating a 'prev' field in tree_node. IMO the cleanest
> approach, but increases memory usage.
>
Yep and this increases the size of the code for all nodes :
statements as well as expressions that doesn't even use the 'chain' field.
> - Do nothing. Every pass that needs to keep TREE_PREV pointers
> should save 'prev' while traversing, and/or use the CFG to find
> predecessors. The second option is what we use once we have
> the CFG.
>
Yes but a 'prev' pointer is really difficult and expensive to maintain
if the transformation has to insert new stmts in the stmt chain.
(execution speed, writing code, maintaining code, ...)
> We need to find a balance between implementation complexity and
> compilation time. No doubt that having TREE_PREV will help some
> traversals, particularly those that are done before the CFG is
> built.
>
> However, the presence of TREE_PREV means that we have to go
> through every line of code that manipulates trees and make sure
> that every time we chain two tree statements, the TREE_PREV field
> of the second statement is updated properly.
>
Not if we keep this modification locally.
Seb