Mike Acton used to say that a compiler can only help solve about 10% of your problem domain; the rest you have to do yourself. That was many years ago. Has something changed? Yes, with the introduction of new compilers and JIT compilers, the situation is much worse, and to have optimal code, we often need to pay more attention to what the compiler is doing (not less).
This lecture will explain why compilers are very complicated and why optimal native code generation is complex and might ruin your day.