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

E-graph showdown: devs split between “overhyped” and “game changer”

TLDR: Cranelift’s new optimizer leans on a simpler “sea-of-nodes” approach and downplays fancy e-graph tricks. The comments split: skeptics call the problem overhyped, fans love the pragmatic design, and everyone wants to know if the speed gains are worth the compile-time cost.

Cranelift just dropped a deep dive on its new mid-level optimizer, an "acyclic e-graph"—think a smart way to spot code that’s basically the same and clean it up. The twist? The author says the flashy bit (bundling many equivalent code forms) might not matter as much as the simpler, sea-of-nodes style that ties all the pieces together. Translation: less math magic, more practical wiring.

Cue the comments. Skeptics like pizlonator—a self-identified compiler writer—rolled in hot, arguing the infamous “which pass runs first?” problem is overblown and you can just merge the relevant steps anyway. Fans pushed back, saying the post shows how to avoid the trap of full-on “equality saturation” (a heavy, exhaustive rule-application technique) and still get wins. PoignardAzur wasn’t shocked that skipping some e-graph bells and whistles still works: “I’m not super surprised.”

Meanwhile, real-world folks chimed in: j2kun (crypto compiler world) called it super helpful, and others pointed to related work like Tamagoyaki. But the meme of the day? Sea-of-nodes vs. sea-of-drama—especially with pjmlp noting the “complexity tax” teams pay when they ditch classic designs. And 0xnadr asked the money question: does all this cleverness add compile-time cost for runtime gains? Popcorn, please. Check out Cranelift for the receipts.

Key Points

  • Cranelift’s mid-end optimizer centers on an acyclic e-graph (aegraph) introduced in 2022 and refined through a full rewrite and community feedback.
  • The article emphasizes a sea-of-nodes-first approach, treating translation passes and node representation as more fundamental than multi-representation e-classes.
  • Alias analysis with redundant load elimination and store-to-load forwarding delivered real speedups (e.g., ~5% on a meshoptimizer benchmark).
  • Interactions among passes like RLE and GVN expose the pass-ordering problem, often requiring multiple iterations to reach a fixpoint.
  • An initial ad-hoc integration invoked GVN after alias-analysis rewrites, highlighting inefficiency and motivating the aegraph-based solution.

Hottest takes

"This post makes it seem like the pass ordering problem is bigger than it really is" — pizlonator
"This article is super helpful seeing how it materialized in a real-world scenario" — j2kun
"Curious how much compile-time overhead it adds vs the optimization wins it gets" — 0xnadr
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.