Superoptimization

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Short description Template:Use dmy dates Template:Use list-defined references Superoptimization is the process where a compiler automatically finds the optimal sequence for a loop-free sequence of instructions. Real-world compilers generally cannot produce genuinely optimal code, and while most standard compiler optimizations only improve code partly, a superoptimizer's goal is to find the optimal sequence, the canonical form. Superoptimizers can be used to improve conventional optimizers by highlighting missed opportunities so a human can write additional rules.

History

The term superoptimization was first coined by Alexia Massalin in the 1987 paper Superoptimizer: A Look at the Smallest Program.[1] The label "program optimization" has been given to a field that does not aspire to optimize but only to improve. This misnomer forced Massalin to call her system a superoptimizer, which is actually an optimizer to find an optimal program.[2]

In 1992, the GNU Superoptimizer (GSO) was developed to integrate into the GNU Compiler Collection (GCC).[3][4] Later work further developed and extended these ideas.

Techniques

Traditionally, superoptimizing is performed via exhaustive brute-force search in the space of valid instruction sequences. This is a costly method, and largely 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, vastly improving the search efficiency (although inputs more complex than a basic block remains out of reach).[5]

In 2001, goal-directed superoptimizing was demonstrated in the Denali project by Compaq research.[6] In 2006, answer set declarative programming was applied to superoptimization in the Total Optimisation using Answer Set Technology (TOAST) project[7] at the University of Bath.[8][9]

Superoptimization can be used to automatically generate general-purpose peephole optimizers.[10]

Publicly available superoptimizers

Several superoptimizers are available for free download.

  • For the x86 family of instruction sets:
  • For ARM:
    • Unbounded Superoptimizer,[5] transforming LLVM IR into ARMv7-A assembly
  • For embedded systems:
  • For the JVM:
  • For LLVM IR:
    • souper[19] superoptimizer for programs in the LLVM intermediate language.
  • For WebAssembly
    • slumps[20] provides superoptimization for WASM programs based on souper.

See also

References

Template:Reflist

Template:Compiler optimizations

  1. Cite error: Invalid <ref> tag; no text was provided for refs named Massalin_1987_Superoptimizer
  2. Cite error: Invalid <ref> tag; no text was provided for refs named Denali
  3. a b Cite error: Invalid <ref> tag; no text was provided for refs named GCCsuperACM
  4. a b Cite error: Invalid <ref> tag; no text was provided for refs named GCCsuperopt
  5. a b Script error: No such module "citation/CS1".
  6. Cite error: Invalid <ref> tag; no text was provided for refs named Joshi_2001
  7. Cite error: Invalid <ref> tag; no text was provided for refs named TOAST-KRR
  8. Cite error: Invalid <ref> tag; no text was provided for refs named TOAST-book
  9. Cite error: Invalid <ref> tag; no text was provided for refs named crick-phd
  10. Cite error: Invalid <ref> tag; no text was provided for refs named Bansal_2006
  11. Cite error: Invalid <ref> tag; no text was provided for refs named GSO_1992
  12. Cite error: Invalid <ref> tag; no text was provided for refs named STOKE
  13. Cite error: Invalid <ref> tag; no text was provided for refs named Bansal_2008
  14. Cite error: Invalid <ref> tag; no text was provided for refs named Serpell_2003_1
  15. Cite error: Invalid <ref> tag; no text was provided for refs named Serpell_2003_2
  16. Cite error: Invalid <ref> tag; no text was provided for refs named Embecosm_2014
  17. Superoptimization – Embecosm Source Code
  18. Cite error: Invalid <ref> tag; no text was provided for refs named Hume_2012
  19. Cite error: Invalid <ref> tag; no text was provided for refs named souper
  20. Cite error: Invalid <ref> tag; no text was provided for refs named slumps