5 lessons
Basic blocks and control flow graphs
Chopping TAC into straight-line chunks with no internal jumps, and connecting those chunks into a graph that shows every possible path through a program.
Local optimizations and common subexpression elimination
Cleaning up redundant work within a single basic block — dead code elimination, copy propagation, constant folding, and common subexpression elimination — all implemented in C++.
Data flow analysis: constant propagation and liveness, across the whole graph
Extending optimization beyond a single basic block using data flow equations, worked by hand and in C++, for global constant propagation and liveness analysis.
Peephole optimization and loop optimizations
Small-window machine-code cleanups you can spot by eye, plus the classic loop optimizations — loop-invariant code motion, strength reduction, and induction variable elimination — worked by hand.
Putting it together, a complete optimization pipeline
How real compilers order and repeat local optimizations and data flow analyses into one coherent pipeline, traced end to end on a full example.