Superoptimization


Superoptimization is the process of automatically finding the optimal code sequence for one loop-free sequence of instructions. It is performed in and by a type of computer software termed a compiler. Real-world compilers generally cannot produce genuinely optimal code. While most standard compiler optimizations only improve code partly, a superoptimizer's goal is to find the optimal sequence, the canonical form.
The term superoptimization was first coined by Alexia Massalin in the 1987 paper Superoptimizer: A Look at the Smallest Program.
Superoptimizers are commonly used to improve conventional optimizers, by highlighting missed opportunities so a human can write additional rules. In 1992, the GNU Superoptimizer was developed to integrate into the GNU Compiler Collection. Later work further developed and extended these ideas. In 2001, goal-directed superoptimizing was demonstrated in the Denali project by Compaq research. In 2006, answer set declarative programming was used for superoptimising in the Total Optimisation using Answer Set Technology project at the University of Bath, and superoptimizing was used to automatically generate general-purpose peephole optimizers.
Typically, superoptimizing is performed via exhaustive brute-force search in the space of valid instruction sequences. This is a costly method, and thus impractical for general-purpose compilers. Yet, it has been shown to be useful in optimizing performance-critical inner loops. It is also possible to use a SMT solver to approach the problem.

Publicly available superoptimizers

Superoptimizer studies, documents, and several working examples, are available for free download.