r/Compilers • • 28d ago

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

16 comments sorted by

View all comments

2

u/adityazero 27d ago

Yes LLMs have huge advantage being inside the compiler. LLMs are a powerful pattern matching engine, and guess what compilers are?

Most people dont get it as we have been seasoned to expect compilers to be of a certain kind. The last impediment to this is determinism (LLMs are not quite deterministic yet) but I would not hold it against LLMs as there are ways to make them deterministic (and this is a novel problem statement for current compiler PhDs)

It is only a matter of time 1-2 years max where you'll see LLMs (at least the fast models) being used in compilers. LLVM already has some (regalloc and inliner using MLGO) which are early stage but I estimate LLMs to be prevalent in compilers, maybe in a different compiler stack.

1

u/Signal-Scholar1299 27d ago

Thanks for the response, Could you explain regalloc and inliner ?

Pattern matching seems limited to the deep semantic understanding and reasoning of llm.

Question was more can llm reasoning or semantic understanding do things that a compiler can not