{"slug": "keep-it-ssa-stupid", "title": "Keep it SSA, stupid", "summary": "A developer's experiment testing whether large language models reason more easily about static single assignment (SSA) code than mutable-variable code generated 40 small programs, each threading three variables through eight steps of branches and helper calls, written in three notations: mutable Rust, single-assignment Rust, and LLVM IR compiled from the mutable Rust. The hypothesis, published in a blog post, is that LLMs will find SSA-style code easier to reason about than code with mutable variables, drawing an analogy to word2vec's dense versus context-dependent token embeddings. The work builds on borrIR, a borrow checker and toolchain for raw LLVM IR the author previously released on GitHub.", "body_md": "Ever since I have been coding agentically the last few months, looking less and less at the actual code, I have been looking to better understand my relationship with code itself.\n\nI seem to still “prefer” language implementations because I steer the agents through them, using the language as a scaffold for reasoning and communication.\n\nDoes it even matter? I know it’s an overused analogy but I don’t care about which instructions the compilers emit, as long as the meaning is preserved and performance is acceptable.\n\nI tried taking this to an extreme: I wanted to see if I could work entirely with the low-level representation, bypassing human-readable languages altogether.\n\nIn my [last post](https://fzakaria.com/2026/11/27/programming-languages-are-for-humans)\nI built [borrIR](https://github.com/fzakaria/borrir), a borrow checker and\ntoolchain for raw LLVM IR.\n\nMost of the motivation was pure commitment to agentic programming: if our dutiful clankers are writing all the code anyway, why keep a human-facing front-end?\n\nBeyond the sensationalized motivation, I had a deeper *gut feeling* that there could be a benefit to working directly with a lower-level representation of code.\n\nHave you tried to code in OCaml or Haskell? It’s wonderful but it definitely requires more cognitive effort to keep track of all the types and abstractions in your head.\n\nCould the same be true for our clankers?\n\nAre all tokens of equal density in the context?\n\nIn 2013 a team at Google published [word2vec](https://arxiv.org/abs/1301.3781).\nIt turns every word into a vector, a list of numbers learned from the company\nthe word keeps. By treating words as vectors, we can perform arithmetic on their meanings\nand discover relationships between them: \n\nThis continues to be my *basic* understanding of how LLMs work. An LLM still starts this way.\nEvery token is looked up in a table and comes out as one vector.\n\nIn our embeddings not all vectors are equally informative. Some words have dense, specific representations, while others are more diffuse and context-dependent. Take *queen* for example: its vector is highly specific and informative whereas *bank* is more ambiguous and context-dependent. One vector has to cover multiple senses, so the model relies on the surrounding context to disambiguate it.\n\nThe same is true for mutable variables.\n\nWhen variable names are reused for different values, the model has to rely on context to disambiguate them, just like it does with polysemous words in natural language.\n\nCompilers face a similar challenge when reasoning about programs with mutable variables, and by and large, gave up. \nGCC, LLVM, Go, V8 and HotSpot all lower your program into [static single assignment](https://en.wikipedia.org/wiki/Static_single-assignment_form) before they try to reason about it.\n\n**Tip**\nIn SSA every value gets one name, once. Nothing is mutated in place and\nnothing shadows an outer variable. A name means the same thing everywhere it\nappears.\n\nIf mutable assignments are hard for compilers to reason about, they are likely hard for LLMs to reason about as well.\n\nThis is my hypothesis: LLMs will find SSA-style code easier to reason about than code with mutable variables.\n\n## [§](#does-an-llm-read-ir-better-than-rust)Does an LLM read IR better than Rust?\n\nThe evaluation setup was designed to test whether LLMs find SSA-style code easier to reason about than code with mutable variables. In order to make a fair comparison, each program was written in three different notations:\n\n1. **Mutable Rust** : ordinary Rust with`let mut` and reassignment.\n2. **Single-assignment Rust** : the same Rust, with a fresh name for every new\nvalue.\n3. **LLVM IR** : the compiled SSA form of the mutable Rust.\n\nI generated 40 different small programs. Each one threads three variables through eight\nsteps of branches and helper calls, and each one exists in three notations\nthat return the same value:<sup>1</sup>1Compiled with `rustc -C opt-level=0` followed by `opt -passes=sroa,mem2reg,instnamer`. \n\nEach variant was given to Claude Haiku with every tool turned off and asked\nthe same question: what integer does `target(seed)` return?\n\nThe program was then made intentionally more complex with clutter that does not affect the final result: inner blocks that shadow variables, dead branches, and decoy functions.\n\nThe smaller model struggled more with the mutable Rust notation, making more mistakes and showing a clearer benefit from the SSA form in single-assignment Rust or LLVM IR.\n\nTurns out that the clutter made no difference for the model’s performance on mutable Rust. The accuracy remained around 80% regardless of the amount of clutter and the failure was on account of the similarity between consecutive steps, which made it easy to confuse the current value of a variable with its previous value.\n\nThat is the whole raison d’être of single-assignment Rust and SSA: each value gets a fresh name, so there is no ambiguity.\n\nHere are two consecutive steps from one of the programs:\n\n```\nif acc > aux {\n    acc = helper_1(acc, aux);\n    tag = tag.wrapping_add(1);\n} else {\n    aux = aux.wrapping_sub(18);\n    acc = (acc.wrapping_add(aux ^ 14)) & 2047;\n}\nif acc > aux {\n    acc = helper_1(acc, aux);\n    tag = tag.wrapping_add(8);\n} else {\n    aux = aux.wrapping_sub(14);\n    acc = (acc.wrapping_add(aux ^ 2)) & 2047;\n}\n```\n\nThe density of assignments to `acc` is high, which increases the likelihood of confusion between consecutive steps along with the\ncomplexity of the expressions on the right-hand side, which makes it easy to lose track of which value belongs to which step.\n\n`acc = (acc.wrapping_add(aux ^ 14)) & 2047;` is an add, an xor, a mask and a write. IR puts one operation on each line. \nThis needs *a lot more* lines to represent the same computation but it makes each step unambiguous and easier for the model to track.\n\nAt the scale of my evaluation, a larger model does handle the ambiguity better but a larger benchmark would likely reveal the limits of even larger models, especially as the programs grow in complexity and the density of assignments increases.\n\nThe main downside of raw IR is verbosity, but this verbosity is exactly what helps the model avoid confusion between consecutive steps.\n\nThe disparity between the two implementations in token output seems to diminish over time. Confused? So was I.\n\nI gave both Claude Haiku and Claude Sonnet the same tiny starter program in\nRust and in `borrIR` (raw zero-libc LLVM IR), then asked for 10 cumulative\nfeatures in a row.<sup>2</sup>2Both Haiku and Sonnet achieved a perfect score of 10/10 on the first try with zero regressions in raw LLVM IR. \n\nIn a standalone file, raw LLVM IR is 3–5× more verbose than Rust. After multiple sequential feature turns, however, the overhead diminishes: 1.15× on Sonnet and 1.49× on Haiku.\n\nHaiku finished the LLVM IR session 30 seconds faster than the\nRust one (`174s` vs. `205s`) as the cherry on top.\n\nMaybe the downside is not as significant as it initially appears, *at least for writing code*.\n\nThere is something here that I will continue to ponder. Just because LLMs are approaching super-intelligence does not preclude them\nfrom benefiting from simpler representations like SSA.  The [Dunning-Kruger effect](https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect) is strong for me, so I am usually emboldened to question basic principles and assumptions that others might take for granted.\n\nAnother analogy I draw from is how CPUs are able to do incredibly complex computations efficiently by breaking them down into simpler, well-defined micro-operations. We can think of SSA as providing a similar kind of simplification for LLMs when reasoning about code.\n\nMy goal is to author the next project purely in LLVM IR and see where it takes me.\n\nIn the meantime, be nice to our clankers. Keep it SSA, stupid.", "url": "https://wpnews.pro/news/keep-it-ssa-stupid", "canonical_source": "https://fzakaria.com/2026/11/28/keep-it-ssa-stupid", "published_at": "2026-11-28 22:00:00+00:00", "updated_at": "2026-11-29 23:13:02.684944+00:00", "lang": "en", "topics": ["large-language-models", "ai-research", "developer-tools", "ai-agents"], "entities": ["LLVM", "borrIR", "GitHub", "Google", "word2vec", "Rust", "GCC", "V8"], "also_reported_by": [], "takeaway": "The author's hypothesis is that LLMs reason more easily about SSA-form code than mutable-variable code, tested across 40 programs each threading three variables through eight steps of branches and helper calls in mutable Rust, single-assignment Rust, and LLVM IR.", "recommendation": {"advice": "When testing whether code notation affects LLM reasoning, hold program semantics fixed and vary only the representation, as this setup did with 40 programs in mutable Rust, single-assignment Rust, and LLVM IR.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/keep-it-ssa-stupid", "markdown": "https://wpnews.pro/news/keep-it-ssa-stupid.md", "text": "https://wpnews.pro/news/keep-it-ssa-stupid.txt", "jsonld": "https://wpnews.pro/news/keep-it-ssa-stupid.jsonld"}}