This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: IPA Constant Propagation Optimization
- From: Chris Lattner <sabre at nondot dot org>
- To: Razya Ladelsky <RAZYA at il dot ibm dot com>
- Cc: gcc at gcc dot gnu dot org, Mircea Namolaru <NAMOLARU at il dot ibm dot com>
- Date: Thu, 13 May 2004 11:00:39 -0500 (CDT)
- Subject: RE: IPA Constant Propagation Optimization
Razya Ladelsky wrote:
> Following our message ( http://gcc.gnu.org/ml/gcc/2003-11/msg01243.html )
> regarding IPA constant propagation, we enclose the first draft
> of the optimization.
If you're interested in IPCP, you might want to check out the LLVM
implementation. It's a very simple algorithm that doesn't modify
functions whose addresses are taken, but is quite effective, trivially
fast, and is only 80 SLOC of code:
http://llvm.cs.uiuc.edu/doxygen/IPConstantPropagation_8cpp-source.html
It should eventually be changed to use a worklist of functions instead of
iterating, but it is so fast that noone has bothered yet.
For example, on povray (+libpng +zlib) it IPCP's 23 args in 0.0048s at
compile-time and 50 more args in 0.0055s at link-time.
On 176.gcc, it IPCP's 13 args in 0.0055s at compile time and IPCP's 61
args in 0.0147s.
These are wall times to run a debug build of the optimization on a 3GHz
machine. We run IPCP both at compile and link time because its fast and
because static functions and code in anonymous namespaces are suprisingly
common.
As always, if you want to play with this (or any other LLVM optimization)
you can do so on the demo page: http://llvm.cs.uiuc.edu/demo/
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/