Next: Introduction to three-address code optimization
Up: Compiler Theory: Code Optimization
Previous: Compiler Theory: Code Optimization
CODE OPTIMIZATION. The target code generated by compilers
is still not as good as code produced by an expert assembly language programmer.
- Compilers need to perform code improving transformations
in order to reduce the running time of the target code.
- Such transformations are called optimization
though very rarely will the code be optimal
in the formal sense of the word.
- The transformations performed by an optimizing compiler
should satisfy the following properties:
- the transformation should preserve the meaning (semantics) of programs,
- the transformation should, on average, speed up programs by a measurable amount,
- though the size of programs is not generally an issue in itself,
it should remain reasonable.
- the amount of compiler effort put into optimizing a section of code
should be relative to
- the number of times the code will be run
- to the entire program
In general code optimization problems
- are NP-complete and
- thus we cannot expect to find a global optimum in a reasonable amount of time.
- Hence the strategy is mainly based on heuristics, that is
- identify hot areas
and put a lot of resources into optimizing these.
Some examples of hot areas
- loops and nested loops
- optimize or eliminate procedure calls
- recognize common subexpressions
- propagate constants
- and lots lots more
Next: Introduction to three-address code optimization
Up: Compiler Theory: Code Optimization
Previous: Compiler Theory: Code Optimization
Marc Moreno Maza
2004-12-02