Hacker News Viewer

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

by tekknolagi on 4/10/2026, 12:37:27 PM

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

Comments

by: j2kun

I work in an esoteric compiler domain (compilers for fancy cryptography) and we&#x27;ve been eyeing e-graphs for a bit. This article is super helpful seeing how it materialized in a real-world scenario.<p>An interesting move in this direction is the Tamagoyaki project: <a href="https:&#x2F;&#x2F;github.com&#x2F;jumerckx&#x2F;Tamagoyaki" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jumerckx&#x2F;Tamagoyaki</a> that supports equality saturation directly in MLIR.

4/14/2026, 3:54:26 PM


by: pjmlp

&gt; While that kind of flexibility is tempting, it comes with a significant complexity tax as well: it means that reasoning through and implementing classical compiler analyses and transforms is more difficult, at least for existing compiler engineers with their experience, because the IR is so different from the classical data structure (CFG of basic blocks). The V8 team wrote about this difficulty recently as support for their decision to migrate away from a pure Sea-of-Nodes representation.<p>Note that the Sea of Nodes author, Cliff Click, is the opinion they weren&#x27;t really using the way they should, and naturally doesn&#x27;t see a point on their migration decision.<p>There is a Coffee Compiler Club discussion on the subject.

4/14/2026, 2:25:13 PM


by: pizlonator

Compiler writer here.<p>This post makes it seem like the pass ordering problem is bigger than it really is and then overestimates the extent to which egraphs solve it.<p>The pass ordering problem isn’t a big deal except maybe in the interaction of GVN and load elimination, but practically, that ends up being a non issue because its natural to make those be the same pass.<p>Aside from that, pass ordering isn’t a source of sweat for me or my colleagues. Picking the right pass order is fun and easy compared to the real work (designing the IR and writing the passes).<p>When pass ordering does come to bite you, it’s in a way that egraphs won’t address:<p>- You need to run some pass over a higher level IR, some other pass over a lower level IR (ie later), and then you discover that the higher level pass loses information needed by the lower level one. That sucks, but egraphs won’t help.<p>- You might have some super fancy escape analysis and some super fancy type inference that ought to be able to help each other but can only do so to a limited extent because they’re expensive to run repeatedly to fixpoint and even then they can’t achieve optimality. Both of them are abstract interpreters from hell. Too bad so sad - your only full solution is creating an even more hellish abstract interpreter. Egraphs won’t help you.<p>- Your tail duplication reveals loops so you want to run it before loop optimization. But your tail duplication also destroys loops so you want to run it after loop optimization. No way around this if you want to do fully aggressive taildup. I end up just running it late. I don’t think egraphs will help you here either.<p>Worth noting that the first problem is sort of theoretical to me, in the sense that I’ve always found some ordering that just works. The second problem happens, but when it does happen, it’s reasonable to have high level and low level versions of the optimizations and just do both (like how the FTL does CSE in three IRs). The last problem is something I still think about.

4/14/2026, 2:17:44 PM


by: PoignardAzur

&gt; <i>Finally, the most interesting question in my view: [...] does skipping equality saturation take the egraph goodness out of an egraph(-alike)? The most surprising conclusion in all of the data was, for me, that aegraphs (per se) -- multi-value representations -- don&#x27;t seem to matter.</i><p>I&#x27;m not super surprised.<p>As the article points out, a lot of e-graph projects include rules for culling e-nodes or stopping generation after a certain cutoff. That this is considered a perfectly normal thing to do hints that equality saturation isn&#x27;t really the magic sauce of e-graphs.

4/11/2026, 5:47:38 PM