egg: Fast and Extensible E-graphs

04/07/2020
by   Max Willsey, et al.
0

An e-graph efficiently represents a congruence relation over many expressions. Although they were originally developed in the late 1970s for use in automated theorem provers, a more recent technique known as equality saturation repurposes e-graphs to implement state-of-the-art, rewrite-driven compiler optimizations and program synthesizers. However, e-graphs remain unspecialized for this newer use case. Equality saturation workloads exhibit distinct characteristics and often require ad hoc e-graph extensions to incorporate transformations beyond purely syntactic rewrites. This work contributes two techniques that make e-graphs fast and extensible, specializing them to equality saturation. A new amortized congruence closure algorithm called rebuilding takes advantage of equality saturation's distinct workload, providing asymptotic speedups over current techniques in practice. A general mechanism called e-class analyses integrates domain-specific analyses into the e-graph, reducing the need for ad hoc manipulation. We implemented these techniques in a new open-source library called egg. Our case studies on three previously published applications of equality saturation highlight how the flexibility of e-class analyses supports diverse domains and how egg can provide up to 3000x speed ups.

READ FULL TEXT
research
04/07/2020

egg: Easy, Efficient, and Extensible E-graphs

An E-graph is a data structure that can efficiently encode the congruenc...
research
05/30/2023

Colored E-Graph: Equality Reasoning with Conditions

E-graphs are a prominent data structure that has been increasing in popu...
research
11/23/2021

Caviar: An E-graph Based TRS for Automatic Code Optimization

Term Rewriting Systems (TRSs) are used in compilers to simplify and prov...
research
03/28/2023

Dias: Dynamic Rewriting of Pandas Code

In recent years, dataframe libraries, such as pandas have exploded in po...
research
01/18/2022

Lambda the Ultimate SSA: Optimizing Functional Programs in SSA

Static Single Assignment (SSA) is the workhorse of modern optimizing com...
research
11/25/2021

Sketch-Guided Equality Saturation: Scaling Equality Saturation to Complex Optimizations of Functional Programs

Generating high-performance code for diverse hardware and application do...
research
04/10/2023

Better Together: Unifying Datalog and Equality Saturation

We present egglog, a fixpoint reasoning system that unifies Datalog and ...

Please sign up or login with your details

Forgot password? Click here to reset