The acyclic e-graph: Cranelift's mid-end optimizer

https://cfallin.org/blog/2026/04/09/aegraph/

Article

  • Cranelift (WebAssembly compiler) adopts acyclic e-graphs (aegraphs) for mid-end optimization
  • Aegraphs represent multiple equivalent program forms simultaneously, enabling better optimization
  • Solves the pass-ordering problem: no need to sequence GVN, DCE, and other passes manually
  • Surprising finding: multi-value representation alone may not be the key benefit

Discussion

  • Compiler writer argues pass-ordering problem is overstated; GVN+load elimination is the main real case
  • E-graphs also applicable to type checkers and trait solvers, not just codegen (Rust’s trait solver cited)
  • egg library (egraphs-good.github.io) referenced as the earlier popularizer of the approach
  • Curiosity about compile-time overhead tradeoffs of the e-graph approach

Discuss on HN


Type Link
Added Apr 15, 2026
Modified Apr 15, 2026