Skip to main content

Common subexpressions are uncommon in lazy functional languages

  • Conference paper
  • First Online:
  • 132 Accesses

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1467))

Abstract

Common subexpression elimination is a well-known compiler optimisation that saves time by avoiding the repetition of the same computation. In lazy functional languages, referential transparency renders the identification of common subexpressions very simple. More common subexpressions can be recognised because they can be of arbitrary type whereas standard common subexpression elimination only shares primitive values. However, because lazy functional languages decouple program structure from data space allocation and control flow, analysing its effects and deciding under which conditions the elimination of a common subexpression is beneficial proves to be quite difficult. We developed and implemented the transformation for the language Haskell by extending the Glasgow Haskell compiler. On real-world programs the transformation showed nearly no effect. The reason is that common subexpressions whose elimination could speed up programs are uncommon in lazy functional languages.

This is a preview of subscription content, log in via an institution.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. A Aho, R Sethi, and J Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1986.

    Google Scholar 

  2. Adrew W Appel. Compiling with Continuations. Cambridge University Press, 1992.

    Google Scholar 

  3. Olaf Chitil. Adding an optimisation pass to the Glasgow Haskell compiler. ttp://www-i2.informatik.rwth-aachen.de/~chitil/, November 1997.

    Google Scholar 

  4. The Glasgow Haskell compiler. ttp://www.dcs.gla.ac.uk/fp/software/ghc/.

    Google Scholar 

  5. Simon D Marlow. Deforestation for Higher-Order Functional Programs. PhD thesis, University of Glasgow, September 1995.

    Google Scholar 

  6. Christian Mossin, David N Turner, and Philip Wadler. Once upon a type. Technical Report TR-1995-8, University of Glasgow, 1995. Extended version of [?].

    Google Scholar 

  7. Will Partain. The Nofib benchmark suite of Haskell programs. In Functional Programming, Glasgow 1992, Workshops in Computing, pages 195–202. Springer-Verlag, 1992.

    Google Scholar 

  8. Will Partain. How to add an optimisation pass to the Glasgow Haskell compiler (two months before version 0.23). Part of the GHC 0.29 distribution, October 1994.

    Google Scholar 

  9. John Peterson, Kevin Hammond, et al. Report on the Programming Language Haskell, version 1.4. ttp://www.haskell.org, 1997.

    Google Scholar 

  10. Simon L Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, 1987.

    Google Scholar 

  11. Simon L Peyton Jones. Implementing lazy functional languages on stock hardware: the Spinless Tagless G-machine. J. Functional Programming, 2(2): 127–202, 1992.

    Article  Google Scholar 

  12. Simon L Peyton Jones and John Launchbury. Unboxed values as first class citizens in a non-strict functional language. In Conf. on Functional Programming Languages and Computer Architecture, pages 636–666, 1991.

    Google Scholar 

  13. Simon L Peyton Jones and André L M Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 1997.

    Google Scholar 

  14. Patrick M Sansom and Simon L Peyton Jones. Time and space profiling for nonstrict, higher-order functional languages. In 22nd ACM Symposium on Principles of Programming Languages, January 1995.

    Google Scholar 

  15. André L M Santos. Compilation by transformation in non-strict functional languages. PhD thesis, University of Glasgow, July 1995.

    Google Scholar 

  16. D Tarditi, G Morrisett, P Cheng, C Stone, R Harper, and P Lee. TIL: A type-directed optimizing compiler for ML. In Sigplan Symposium on Programming Language Design and Implementation, 1996.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Chris Clack Kevin Hammond Tony Davie

Rights and permissions

Reprints and permissions

Copyright information

© 1998 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Chitil, O. (1998). Common subexpressions are uncommon in lazy functional languages. In: Clack, C., Hammond, K., Davie, T. (eds) Implementation of Functional Languages. IFL 1997. Lecture Notes in Computer Science, vol 1467. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0055424

Download citation

  • DOI: https://doi.org/10.1007/BFb0055424

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-64849-9

  • Online ISBN: 978-3-540-68528-9

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics