insecure <insecure@xxxxxxxxxx> writes:movl $0, 20(%esp)
movl $1000000, %edi <----
movl $1000000, 16(%esp) <----
movl $0, 12(%esp)
No sane human will do that.
main:
movl $1000000, %edi
movl %edi, 16(%esp) <-- save 4 bytes
movl %ebp, 12(%esp) <-- save 4 bytes
movl $.LC27, 8(%esp)
And this is only from a cursory examination.
Actually it is no as simple as that. With the instruction that uses
%edi following immediately after the instruction that populates it you cannot
execute those two instructions in parallel. So the code may be slower. The
exact rules depend on the architecture of the cpu.
What gives you an impression that anyone is going to rewrite linux in asm?
I _only_ saying that compiler-generated asm is not 'good'. It's mediocre.
Nothing more. I am not asm zealot.
I think I would agree with that statement most compiler-generated assembly
code is mediocre in general. At the same time I would add most human
generated assembly is poor, and a pain to maintain.
If you concentrate on those handful of places where you need to
optimize that is reasonable. Beyond that there simply are not the
developer resources to do good assembly. And things like algorithmic
transformations in assembly are an absolute nightmare. Where they are
quite simple in C.
And if the average generated code quality bothers you enough with C
the compiler can be fixed, or another compiler can be written that
does a better job, and the benefit applies to a lot more code.