Skip to main content

Optgen: A Generator for Local Optimizations

  • Conference paper

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 9031)

Abstract

Every compiler comes with a set of local optimization rules, such as x + 0 → x and x & x → x, that do not require any global analysis. These rules reflect the wisdom of the compiler developers about mathematical identities that hold for the operations of their intermediate representation. Unfortunately, these sets of hand-crafted rules guarantee neither correctness nor completeness. Optgen solves this problem by generating all local optimizations up to a given cost limit. Since Optgen verifies each rule using an SMT solver, it guarantees correctness and completeness of the generated rule set. Using Optgen, we tested the latest versions of gcc, icc and llvm and identified more than 50 missing local optimizations that involve only two operations.

Keywords

  • Intermediate Representations
  • Local Optimizations
  • Superoptimization

References

  1. Bansal, S., Aiken, A.: Automatic generation of peephole superoptimizers. In: Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS XII, pp. 394–403. ACM, New York (2006)

    Google Scholar 

  2. Braun, M., Buchwald, S., Hack, S., Leißa, R., Mallon, C., Zwinkau, A.: Simple and efficient construction of static single assignment form. In: Jhala, R., De Bosschere, K. (eds.) Compiler Construction. LNCS, vol. 7791, pp. 102–122. Springer, Heidelberg (2013)

    CrossRef  Google Scholar 

  3. De Moura, L., Bjørner, N.: Z3: An efficient smt solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008)

    CrossRef  Google Scholar 

  4. Joshi, R., Nelson, G., Randall, K.: Denali: A goal-directed superoptimizer. In: Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation, PLDI 2002, pp. 304–314. ACM, New York (2002)

    Google Scholar 

  5. libFirm – The FIRM intermediate representation library, http://libfirm.org

  6. Lopes, N., Menendez, D., Nagarakatte, S., Regehr, J.: ALIVe: Automatic LLVM InstCombine Verifier, http://blog.regehr.org/archives/1170

  7. Massalin, H.: Superoptimizer: A look at the smallest program. In: Proceedings of the Second International Conference on Architectual Support for Programming Languages and Operating Systems, ASPLOS II, pp. 122–126. IEEE Computer Society Press, Los Alamitos (1987)

    Google Scholar 

  8. Nelson, G., Oppen, D.C.: Fast decision procedures based on congruence closure. J. ACM 27(2), 356–364 (1980)

    CrossRef  MATH  MathSciNet  Google Scholar 

  9. Schkufza, E., Sharma, R., Aiken, A.: Stochastic superoptimization. In: Proceedings of the Eighteenth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS 2013, pp. 305–316. ACM, New York (2013)

    Google Scholar 

  10. Schkufza, E., Sharma, R., Aiken, A.: Stochastic optimization of floating-point programs with tunable precision. In: Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2014, pp. 53–64. ACM, New York (2014)

    Google Scholar 

  11. Seltenreich, A.: Minimizing bit width using data flow analysis in libfirm (February 2013)

    Google Scholar 

  12. Tate, R., Stepp, M., Tatlock, Z., Lerner, S.: Equality saturation: A new approach to optimization. In: Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, pp. 264–276. ACM, New York (2009)

    Google Scholar 

  13. Wegman, M.N., Zadeck, F.K.: Constant propagation with conditional branches. ACM Trans. Program. Lang. Syst. 13(2), 181–210 (1991)

    CrossRef  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Sebastian Buchwald .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2015 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Buchwald, S. (2015). Optgen: A Generator for Local Optimizations. In: Franke, B. (eds) Compiler Construction. CC 2015. Lecture Notes in Computer Science(), vol 9031. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-46663-6_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-46663-6_9

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-662-46662-9

  • Online ISBN: 978-3-662-46663-6

  • eBook Packages: Computer ScienceComputer Science (R0)