Not going into much detail, because compilers suck ass. Really. They are terrible.
Can you think about some trivial optimization? Well, chances are no compiler implemented it.
Most compilers rock at completely useless optimizations, the kind of high level stuff that can be fixed in the source language already (common subexpressions, dead code, algebraic simplifications...) but their code generation is an embarrassing joke.