Results 1 
2 of
2
Playing by the rules: rewriting as a practical optimisation technique in GHC
"... We describe a facility for improving optimization of Haskell programs using rewrite rules. Library authors can use rules to express domainspecific optimizations that the compiler cannot discover for itself. The compiler can also generate rules internally to propagate information obtained from aut ..."
Abstract

Cited by 56 (9 self)
 Add to MetaCart
We describe a facility for improving optimization of Haskell programs using rewrite rules. Library authors can use rules to express domainspecific optimizations that the compiler cannot discover for itself. The compiler can also generate rules internally to propagate information obtained from automated analyses. The rewrite mechanism is fully implemented in the released Glasgow Haskell Compiler. Our system is very simple, but can be effective in optimizing real programs. We describe two practical applications involving shortcut deforestation, for lists and for rose trees, and document substantial performance improvements on a range of programs. 1 Introduction Optimising compilers perform program transformations that improve the efficiency of the program. However, a compiler can only use relatively shallow reasoning to guarantee the correctness of its optimisations. In contrast, the programmer has much deeper information about the program and its intended behaviour. For example, a programmer may know that
Preliminary Proceedings of the ACM SIGPLAN Haskell Workshop (HW'2001)
, 2001
"... Using Haskell as a digital circuit description language, we transform a ripple carry adder that requires O(n) time to add two nbit words into an e#cient carry lookahead adder that requires O(log n) time. The gain in speed relies on the use of parallel scan to calculate the propagation of carry bits ..."
Abstract
 Add to MetaCart
Using Haskell as a digital circuit description language, we transform a ripple carry adder that requires O(n) time to add two nbit words into an e#cient carry lookahead adder that requires O(log n) time. The gain in speed relies on the use of parallel scan to calculate the propagation of carry bits e#ciently. The main di#culty is that this scan cannot be parallelised directly since it is applied to a nonassociative function. Several additional techniques are needed to circumvent the problem, including partial evaluation and symbolic function representation. The derivation given here provides a formal correctness proof, yet it also makes the solution more intuitive by bringing out explicitly each of the ideas underlying the carry lookahead adder.