This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] AST optimizer in C++?
- From: Chris Lattner <sabre at nondot dot org>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: Diego Novillo <dnovillo at redhat dot com>,Pop Sébastian <pop at gauvain dot u-strasbg dot fr>,<gcc at gcc dot gnu dot org>
- Date: Tue, 27 Aug 2002 12:01:11 -0500 (CDT)
- Subject: Re: [tree-ssa] AST optimizer in C++?
> > Maybe you could work up a patch to tree-ssa-ccp or tree-ssa-pre.c that
> > shows how much easier it would be if we had it in the IR?
> > No need to actually make it *work*, i just want to see an actual
> > benefit in terms of what the code looks like, or how short it is, etc,
> > rather than all theoretical junk.
>
> I'm having a hard time getting access to those files. subversion.gcc.org
> doesn't seem to like displaying branches in viewcvs, and those files don't
> show up here:
Okay I found the code in the Attic directory (is this normal?).
Basically, I think the benefits would be:
* Simpler code. I'm not really sure why you have two loops in
ssa_ccp_substitute_constants, but SCCP should only require one loop of
transformation over the representation to finalize it. In LLVM this
looks like this:
for (Function::iterator BB = F.begin(), BBE = F.end(); BB != BBE; ++BB)
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
Instruction &Inst = *BI;
if (ValueState[&Inst].isConstant()) {
Constant *Const = ValueState[&Inst].getConstant();
// Replaces all of the uses of a variable with uses of the constant.
Inst.replaceAllUsesWith(Const);
// Remove the operator from the list of definitions... and delete it.
BI = BB->getInstList().erase(BI);
} else {
++BI;
}
}
[slightly simplified from
http://llvm.cs.uiuc.edu/doxygen/SCCP_8cpp-source.html#l00239]
why does your SCCP have the extra loop?
* Macros should disappear. Given a structured representation, many of the
macros should go away...
-Chris
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/