To view parent comment, click here.
To read all comments associated with this story, please click here.
Laurence,
"These days compilers are so good at optimising that you're more likely to write better performing code in C than assembly."
There are still times when I find GCC didn't optimize something as well as it could have, especially when the C code doesn't translate directly to the desired architecture opcode (many bit manipulation, overflow flags, and multi-word-size instructions are completely absent in C). The roundabout algorithm in C will sometimes result in a roundabout assembly optimization.
That said, most of us have thrown in the towel because the business case for hand optimization skills is virtually non-existent. Most businesses are willing to let grossly inefficient code slide by if they can trade off developer costs with better hardware.
Every time this topic comes up someone else points out the the importance of optimizing the algorithm before resorting to assembly, let me preempt this by saying "I agree".
The processors have also become too complex:
- out of order execution
- parallel execution units
- branch prediction
- multiple cache levels
- opcode rewriting
- SIMD
- NUMA
- (put you favourite feature here)
You need to be super human to really optimize for a given processor given all the variables, and when you manage to do it, it is only for a specific model.
Only on the embedded space it is still an advantage to code directly in assembly.
Yeah, its difficult to talk about this in the abstract. If I were in charge of a project, I'd want to see a real performance test between code written with proper data structures and one without to see how much of speed up really exists and how critical that speed up really is to the project. Because often developers write code with prejudiced from past experience that may not be applicable to the current task.
But even today there is a wide range of output from various compilers for different programs. Some do a better job than others for different tasks. If it was really critical ( I agree there aren't many of these situations today), I'd look at the output for different compilers and choose the best output for the task.





Member since:
2007-03-26
These days compilers are so good at optimising that you're more likely to write better performing code in C than assembly.