Go look at the assembler that some of these compilers produce. It's frightening to see the amount of overhead they cost on even simple assignment operations. I saw one compiler (Microsoft's Visual C++) that took a simple x=10; in C++ and turned it into 15 assembly language operations that, had it been coded by hand, would have been one MOV statement.
Spoken like someone who hasn't used a modern compiler.
This statement might have been true ten years ago (or maybe still true with MSC). But in general, with a good modern compiler, it isn't.
In the Z-80 days, I did everything assembly (actually, in raw machine code, compiling in my head, effectively). I learned C in the 8088 days, but did a lot of optimization, putting my CPU intensive stuff in assembler functions. And so forth on the VAX, and into the 386 days, doing graphics work, 3D stuff, games, and such.
Then the Watcom compiler came along, and started pushing what compilers could truly achieve.
It reached a point where, looking at the generated code, I realized that in general, the compiler was doing as good, or very nearly as good a job as I could do. In some cases, with loop unrolling and other "non-local" optimizations, it was doing better. At this bore out in actual performance timing tests. And the other compilers caught up to Watcom, and they all continued to get better and better; my hand-written optimized code had already reached its limit, that the compilers approached.
Granted, there will always be some case where a bit of assembler can optimize things; but with the speed of CPU's, and the quality of modern compilers, the case where it's worth the effort is *exceedingly* rare.
I doubt you could show an example today with the latest GCC, where an assignment resulted in a dozen instructions.
Simple example:
i = 0;
for (j = 0; j < 10; j++)
i += j;
ran through "gcc -O -S", gives:
movl $0, %eax
movl $0, %edx
L2:
addl %edx, %eax
incl %edx
cmpl $10, %edx
jne L2
Hard to beat that (other than figuring out the algorithm and reducing to a constant, which some of the super-advanced compilers probably do :)
And with limited register sets, compilers can be better than humans, at figuring which variables are best stashed in memory or on the stack, and which are best cached in registers.