How do modern optimizing compilers determine when to apply certain optimizations, such as loop unwrapping and code inlining?
Since both of these aspects affect caching, naively inline functions with less than X lines, or any other simple heuristics, are more likely to produce worse executable code. So how do modern compilers handle this?
It's hard for me to find information about this (especially information that is easy enough to understand ..), about the best I could find, this is a wikipedia article . Any details, links to books / articles / articles are welcome!
EDIT: since the answers mostly concern the two optimizations that I mentioned (embedding and loop reversal), I just wanted to clarify that I am interested in all and any compiler optimizations, not just these two. I am also interested in optimizations that may be performed during compilation in the future, although JIT optimization is also of interest (albeit to a lesser extent).
Thanks!
optimization compiler-optimization gcc compiler-construction
Dan
source share