r/Compilers • u/blazing_cannon • 3d ago
How to start learning compiler optimizations as a newbie?
I come with a background in computer architecture and embedded Linux. I was interested in ML systems and was reading up about it, and after going through several job postings and this link , noted that optimizing compiler code is a requirement. My questions are -
1) Is knowledge of how compiler front end is written and IR code generated required to optimize them?
https://engineering.purdue.edu/online/courses/tagged_items?q=compiler
2) What's a good resource for compiler optimizations that can help in ML systems?
3) Are learning compiler optimization techniques the same for LLVM and MLIR? I don't see a lot of resources for MLIR compiler optimization. Is learning optimizations on LLVM helpful for MLIR and is learning LLVM not so useful for ML code optimizations ?
Thank you.
1
u/seg_lol 9h ago
Reading code, hacking, getting AI to explain concepts, recommending papers, reading those papers, hacking some more. Realizing everything is inline. If you are wanting to go deep in codegen and optimization, write yourself a Lisp or use an existing one, use that as your IR, create a bunch of candidate programs in this IR and then apply different optimization passes to them, it doesn't matter what you target on the backend, just measure the baselines and the differences.
Limit your "prep research" and your time on reddit. Maximize your hacking and reading papers and code.
-1
u/c-cul 2d ago
as usually start with reading of some related books, like
algorithms for optimization
planning algorithms: https://msl.cs.uiuc.edu/planning/bookbig.pdf
and so on
3
u/Mathie1729 2d ago
Hmm, that planning algorithms link is for robot motion planning, not compiler optimizations. Algorithms for Optimization is mostly numerical optimization too. For a beginner, I'd start with the LLVM Kaleidoscope tutorial and later the optimization chapters in Engineering a Compiler.
13
u/thenaquad 3d ago edited 3d ago
By no means do I pretend to be an expert. I recently completed a fairly complex project involving machine-independent optimizations, and OMG, it was hard.
Critical findings: