SandeepMathew wrote:
I am happy to know that it is feasible....,Still ther wont come a time when a compiler can generate code better than a master assembly programmer...? Any takers for this.......
Genetic code?
Solar wrote:
But I'd daresay the number of people beating a compiler backend with their "everyday" ASM code recons in the hundreds, at best. And they are getting fewer, simply because the processor architectures grow ever more complex.
As long as you can't sensibly do things with compilers that can be done easily in assembly I think assembly code is in speed superior to compiler code:
Not all compilers are the GCC -O3
You can't tailor register calling conventions, which is especially a burden on x86 where 5 out of 8 registers need to be preserved under standard calling conventions: EBX EBP ESI EDI, and implicitly, ESP
You must help the compiler in order to have it produce SSE code. Even then it's difficult to enforce a memory arrangement that allows optimal vectorisation by the compiler.
You know the exact preconditions and postconditions of function calls, which you can use to your advantage. GCC can only guess at that.
In all, GCC, and virtually all other compilers, are fundamentally limited when it comes to speed.
That said, an asm programmer with some experience will outperform all non-optimizing compilers, with some more experience -O2 gcc can still easily be beaten, and for quite a bit more gurus than you expect -O3 isn't a problem to beat.