A little of Partial Compilation

bearophile bearophileHUGS at lycos.com
Thu Aug 21 06:37:39 PDT 2008


JAnderson:
> I know but I think its more about ordering of functions rather then 
> turning them into templates.

Profile-guided optimization (like the one performed by GCC with the -fprofile-generate/-fprofile-use compilation switches) is meant to do all kind of things, like finding cold/hot functions, find where some cache prefetch may be useful, what are the most frequent results of each branching in the code of the program, to spot what fields of the objects/arrays are frequently accessed close in time (to make those fields closer, or split objects in sub-groups), to find what virtual class methods can be compiled as static, what functions/methods to inline, what loops to unroll and how much unroll them, where to merge loops, where to split matrix iterations into tiles to reduce cache misses, where to make asm code short and where to make it faster&longer, where to put 'aligns' in the asm code, where to unroll recursive calls, where to not convert recursive tail calls into iterations, etc.
At the moment GCC is able to performs some of such optimizations, the Intel C compiler is able to perform other ones, the Intel Fortran compiler is able to do other ones of them, HotSpot compiler of Java is able to do yet other ones. Eventually people will try to put all those together :-)
There are even compilers like the Stalin Scheme compiler (http://community.schemewiki.org/?Stalin ) that try to perform lot of those things statically, without running the program :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list