Louis I. answered 09/28/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Well, you've laid out the proper foundation for answering this question very well ...
Modern C compilers generate pretty efficient assembly language,
and generally speaking, just as high performing as equivalent human-developer code could
ever be. There are exceptions however - I mean in the universe of application
coding solutions across all processor platforms, how could there not be?
There will be times when the compiler insists on generating code that looks like this:
instruction 1
instruction 2
instruction 3
instruction 4
instruction 5
conditional branch -> instruction 1
when it could have been written more efficiently like this without impacting functionality,
therefore saving 2 instructions per iteration:
some other instruction 1
some other instruction 2
some other instruction 3
conditional branch -> some other instruction 1
What's a specific example?
Can't give you one without running into it first hand ...
But as you say, the gained efficiency needs to be balanced against with other realities - such as
the fact that a human developer now needs to maintain processor-specific assembly language
for functionality that could have been coded in C.
When I started coding processionally in 1982, code generators were less optimized, and
processors were many orders of magnitude slower than they are today.
So notional examples like the above [worth addressing with custom assembly code]
would have been more commonplace then than now.
Without hard data to back me up, I'll still go out on a limb here and say that we would be
more hard pressed to encounter such examples in 2019 ...
Anyway, nothing contentious about it if we stay away from general conclusions.
The exceptions to the rule will be context specific:
- application
- C code block
- processor
- ...