Simon Willison’s Weblog: llvm: InstCombine: improve optimizations for ceiling division with no overflow – a PR by Alex Gaynor and Claude Code

Source URL: https://simonwillison.net/2025/Jun/30/llvm/
Source: Simon Willison’s Weblog
Title: llvm: InstCombine: improve optimizations for ceiling division with no overflow – a PR by Alex Gaynor and Claude Code

Feedly Summary: llvm: InstCombine: improve optimizations for ceiling division with no overflow – a PR by Alex Gaynor and Claude Code
Alex Gaynor maintains rust-asn1, and recently spotted a missing LLVM compiler optimization while hacking on it, with the assistance of Claude (Alex works for Anthropic).
He describes how he confirmed that optimization in So you want to serialize some DER?, taking advantage of a tool called Alive2 to automatically verify that the potential optimization resulted in the same behavior.
Alex filed a bug, and then…

Obviously the next move is to see if I can send a PR to LLVM, but it’s been years since I was doing compiler development or was familiar with the LLVM internals and I wasn’t really prepared to invest the time and energy necessary to get back up to speed. But as a friend pointed out… what about Claude?
At this point my instinct was, “Claude is great, but I’m not sure if I’ll be able to effectively code review any changes it proposes, and I’m not going to be the asshole who submits an untested and unreviewed PR that wastes a bunch of maintainer time". But excitement got the better of me, and I asked claude-code to see if it could implement the necessary optimization, based on nothing more than the test cases.

Alex reviewed the resulting code very carefully to ensure he wasn’t wasting anyone’s time, then submitted the PR and had Claude Code help implement the various changes requested by the reviewers. The optimization landed two weeks ago.
Alex’s conclusion (emphasis mine):

I am incredibly leery about over-generalizing how to understand the capacity of the models, but at a minimum it seems safe to conclude that sometimes you should just let the model have a shot at a problem and you may be surprised — particularly when the problem has very clear success criteria. This only works if you have the capacity to review what it produces, of course. […]

This echoes Ethan Mollick’s advice to "always invite AI to the table". For programming tasks the "very clear success criteria" is extremely important, as it helps fit the tools-in-a-loop pattern implemented by coding agents such as Claude Code.
LLVM have a policy on AI-assisted contributions which is compatible with Alex’s work here:

[…] the LLVM policy is that contributors are permitted to use artificial intelligence tools to produce contributions, provided that they have the right to license that code under the project license. Contributions found to violate this policy will be removed just like any other offending contribution.
While the LLVM project has a liberal policy on AI tool use, contributors are considered responsible for their contributions. We encourage contributors to review all generated code before sending it for review to verify its correctness and to understand it so that they can answer questions during code review.

Back in April Ben Evans put out a call for concrete evidence that LLM tools were being used to solve non-trivial problems in mature open source projects:

I keep hearing #AI boosters / talking heads claiming that #LLMs have transformed software development […] Share some AI-derived pull requests that deal with non-obvious corner cases or non-trivial bugs from mature #opensource projects.

I think this LLVM optimization definitely counts!
(I also like how this story supports the idea that AI tools amplify existing human expertise rather than replacing it. Alex had previous experience with LLVM, albeit rusty, and could lean on that knowledge to help direct and evaluate Claude’s work.)
Tags: alex-gaynor, compilers, llvm, open-source, ai-assisted-programming, anthropic, claude, coding-agents, claude-code

AI Summary and Description: Yes

**Summary:** The text details a recent optimization in the LLVM compiler project assisted by an AI tool named Claude Code. The author, Alex Gaynor, emphasizes the importance of clear success criteria when utilizing AI for programming tasks and highlights LLVM’s policy supporting AI contributions, marking a significant milestone in the integration of AI within mature open-source projects.

**Detailed Description:**
The text illustrates a practical example of AI’s role in software development, specifically through the lens of LLVM, a compiler infrastructure project. It describes how Alex Gaynor, with the help of Claude Code (an AI programming agent), identified and implemented a critical optimization in the LLVM codebase, reinforcing the growing collaboration between human developers and AI tools in modern coding practices.

Key points include:

– **AI Assistance in Compiler Development:**
– Alex, who was initially hesitant, engaged Claude Code to implement optimizations based solely on test cases.
– This demonstrates AI’s capacity to contribute to intricate technical tasks by offering fresh perspectives on coding challenges.

– **Importance of Review Processes:**
– Alex emphasizes the necessity of reviewing AI-generated code to ensure correctness and maintain quality control.
– This highlights a crucial relationship between human oversight and AI assistance.

– **LLVM’s AI Policy:**
– The LLVM community allows the use of AI tools for contributions as long as contributors adhere to licensing requirements.
– Contributors are held responsible for reviewing the AI-assisted code, assuring alignment with project standards.

– **Broader Implications for Software Development:**
– This event serves as evidence of how AI tools can help tackle complex problems in established open-source projects.
– The narrative supports the idea that AI does not displace human expertise but rather enhances it, providing significant leverage in problem-solving.

– **Calls for Evidence in AI Application:**
– The text responds to a call from Ben Evans for concrete examples of AI’s impact in solving non-trivial software problems, successfully proving that AI can indeed play a crucial role in coding tasks.

Overall, the text captures a significant moment in the evolution of AI integration within software development, showcasing not only the potential of AI-driven contributions but also the importance of responsible usage and the need for careful oversight in the coding process. For security and compliance professionals, this underscores the importance of establishing clear guidelines and review mechanisms when incorporating AI tools in code repositories.