r/Compilers • • May 04 '26

Control-dependent optimization in Sea of Nodes IR?

14 Upvotes

I am looking for literature on a class of optimizations that are easy to express in classic CFG/SSA form but seem awkward in SoN IR.

In a CFG/SSA representation, control-flow dominance gives us useful facts about the predicates that hold at a given instruction. For example, inside an if (c == 2) block, an expression like x / c may be simplified to x >> 1 or another equivalent form, depending on rounding semantics. This also enables elimination of redundant conditionals. I do not think SCCP captures this generally, at least not in the form presented in Simple.

A second case is expression duplication across branches: if a complex expression X is used in both arms of an if/else, it can sometimes be profitable to duplicate X into each branch so that each copy can be simplified using branch-specific predicates. This is straightforward to detect in CFG/SSA, but much harder in SoN IR before scheduling.

More generally, I am interested in optimizations whose profitability depends on scheduling or placement relative to control flow. In principle, one could schedule first, perform these optimizations, and then reschedule, but that feels somewhat at odds with the SoN philosophy.

Is there existing work on this, or a standard way to handle it?


r/Compilers • • May 03 '26

A Tale of Three WebAssembly Runtimes

Thumbnail csjh.blog
20 Upvotes

r/Compilers • • May 03 '26

HP-48/HP-49 Saturn Assembly translator

Thumbnail github.com
9 Upvotes

Hello all,

Here is my last project, I don't know if we can call it a compiler but this does a part of the compiler job. Let me know if it is really off-topic, I will then delete it.

This takes a C file and translate it to Saturn Assembly language. I consider it mainly finished, I still have to test it on an actual machine, the converted code is theoretically valid. There are bugs that I know the existence of, but not blocking ones.

So here it is if someone may need HP-48 assembly converter.


r/Compilers • • May 02 '26

How long does it take to make a compiler?

49 Upvotes

Currently I am reading the "Engineering a compiler" book, I also made a working interpreter (not complete yet) and I will have 3 months of free time during the summer, so I decided to spend at least 5 hours working on my own compiler(those 5 hours include learning theory and coding the compiler). I plan to make my IR, optimze it a little and then compile to x86 assembly. Is this achievable or am I getting too ahead of myself? Thanks in advance!