3 ms·
Modern compilers can often beat hand-written assembler code in practice. Theoretically they can't, but we don't live in the theoretical world. The common belie
by tasty_freeze 7y ago
Modern compilers can often beat hand-written assembler code in practice. Theoretically they can't, but we don't live in the theoretical world. The common belief is true because most people understand the distinction.
How can that happen? One reason is choice of algorithms -- the same reason why two programmers using the same language to complete the same task can produce remarkably different results.
Another reason is profile-driven optimization -- in theory the assembly language programmer can do this too, but the effort of restructuring lots of handwritten code is too painful. Yes, it is done sometimes (eg, different inner loops for video codecs for different versions of x86 cpus).
Likewise, optimizers and superoptimizers understand the pipeline quirks of specific processors better than most people writing assembly language for x86-type processors and can produce better results.
- Annatar 7y agoCase in point. What you belive is a myth. It's not true. A compiler will never be able to beat a human at writing assembler code. Read any tutorial at constructing compilers to understand why.