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.
References
A Aho, R Sethi, and J Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1986.
Adrew W Appel. Compiling with Continuations. Cambridge University Press, 1992.
Olaf Chitil. Adding an optimisation pass to the Glasgow Haskell compiler. ttp://www-i2.informatik.rwth-aachen.de/~chitil/, November 1997.
The Glasgow Haskell compiler. ttp://www.dcs.gla.ac.uk/fp/software/ghc/.
Simon D Marlow. Deforestation for Higher-Order Functional Programs. PhD thesis, University of Glasgow, September 1995.
Christian Mossin, David N Turner, and Philip Wadler. Once upon a type. Technical Report TR-1995-8, University of Glasgow, 1995. Extended version of [?].
Will Partain. The Nofib benchmark suite of Haskell programs. In Functional Programming, Glasgow 1992, Workshops in Computing, pages 195–202. Springer-Verlag, 1992.
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.
John Peterson, Kevin Hammond, et al. Report on the Programming Language Haskell, version 1.4. ttp://www.haskell.org, 1997.
Simon L Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, 1987.
Simon L Peyton Jones. Implementing lazy functional languages on stock hardware: the Spinless Tagless G-machine. J. Functional Programming, 2(2): 127–202, 1992.
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.
Simon L Peyton Jones and André L M Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 1997.
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.
André L M Santos. Compilation by transformation in non-strict functional languages. PhD thesis, University of Glasgow, July 1995.
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.
Author information
Authors and Affiliations
Editor information
Rights 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