r/Compilers • u/Signal-Scholar1299 • Nov 04 '26
Llm optimization in compiler ?
Has anyone found an optimization that a llm could do when compiling code?
I wonder if llm could bring new kind of optimization to compiler
The only thing I can think of, would be semantic equivalence.
But compiler already does it too (with egraph for example)
0
Upvotes
View all comments
9
u/excuse-my-lisp Nov 04 '26
There are some good reasons why you wouldn't want the compiler itself to invoke an LLM; it'd be much harder to prove that no miscompile occurs (the LLM could unintentionally change the semantic effects of the code), it would be very expensive in terms of time and probably actual cost (compile times are orders of magnitude faster than LLM responses), but most importantly the output would not be deterministic - by design, the LLM would produce different code for the same input when run repeatedly, which is generally a bad property for a compiler to have. It makes much more sense for the LLM to optimize the source code itself, potentially using remarks/diagnostics from the compiler itself as an aid.