Compiling pattern matching to good decision trees

Luc Maranget. Compiling pattern matching to good decision trees. In Eijiro Sumii, editor, Proceedings of the ACM SIGPLAN Workshop on ML. ML'08, pages 35-46, Association for Computing Machinery, New York, NY, USA, 2008. [doi]

Abstract

We address the issue of compiling ML pattern matching to compact and efficient decisions trees. Traditionally, compilation to decision trees is optimized by (1) implementing decision trees as dags with maximal sharing; (2) guiding a simple compiler with heuristics. We first design new heuristics that are inspired by necessity, a concept from lazy pattern matching that we rephrase in terms of decision tree semantics. Thereby, we simplify previous semantic frameworks and demonstrate a straightforward connection between necessity and decision tree runtime efficiency. We complete our study by experiments, showing that optimizing compilation to decision trees is competitive with the optimizing match compiler of Le Fessant and Maranget (2001).