Writing an LLVM Pass
llvm.org
llvm.org
Still, it's definitely the best way to get exposed to writing optimizations using LLVM. Writing optimization passes ends up being really self-contained too (just that one file/class, and it 'automatically' gets registered into the optimizer), so it might be just one of the better ways of learning LLVM overall.