Results 1 
3 of
3
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.
Cobalt: A Language for Writing ProvablySound Compiler Optimizations
, 2005
"... We overview the current status and future directions of the Cobalt project. Cobalt is a domainspecific language for implementing compiler optimizations as guarded rewrite rules. Cobalt optimizations operate over a Clike intermediate representation including unstructured control flow, pointers to lo ..."
Abstract
 Add to MetaCart
We overview the current status and future directions of the Cobalt project. Cobalt is a domainspecific language for implementing compiler optimizations as guarded rewrite rules. Cobalt optimizations operate over a Clike intermediate representation including unstructured control flow, pointers to local variables and dynamically allocated memory, and recursive procedures. The design of Cobalt engenders a natural inductive strategy for proving the soundness of optimizations. This strategy is fully automated by requiring an automatic theorem prover to discharge a small set of simple proof obligations for each optimization. We have written a variety of forward and backward intraprocedural dataflow optimizations in Cobalt, including constant propagation and folding, branch folding, full and partial redundancy elimination, full and partial dead assignment elimination, and simple forms of pointsto analysis. The implementation of our soundnesschecking strategy employs the Simplify automatic theorem prover, and we have used this implementation to automatically prove the above optimizations correct. An execution engine for Cobalt optimizations is implemented as part of the Whirlwind compiler infrastructure.