The compiler tries to optimize what it can, but you have to optimize what you can, and the book should help you with that (somewhat).
If you are going to write significantly large programs, it is very easy to put in slowness, without meaning to, that the compiler could never undo.
My favorite example is here. It consists of a realistically large program that was optimized. It was made faster by 50%. But that did not mean it could not be further optimized. The second attempt knocked out a healthy percent of what was left. But that still wasn't the end. This was done six times, and guess what the overall speedup ratio was?
730 times.
Toward the end, the optimizations being done were, out of the original program's time, so small as to be insignificant. But after a series of other problems were removed, small problems become larger, percentage-wise, so they become worth removing.
The individual speedup ratio that you get with each optimization may not be too surprising, but they multiply together like compound interest.
That's how you can really optimize code.
By all means, use the book, but don't limit yourself to what it says.