Most of a serious modern compiler is devoted to optimization. Correct inefficiencies produced by excessively local code generation strategies. More Peephole Optimizations Algebraic Simplification Strength Reduction Target hardware may have cheaper ways to do certain operations. E.g., multiplication or division by a power of 2 is better done by shifting. Optimizations Typically applied to IR, after addressing is made explicit, but before machine dependencies appear.
Optimizations enable further optimizations.
Optimization Loop optimizations are most important. Use induction variables and reduction in strength. Change only one index variable on each loop iteration, and choose one that's cheap to change. Also continue to apply CSE, copy propagation, dead code elimination, etc. on global scale. Local CSE already performed within basic blocks.