lkml.org 
[lkml]   [2003]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: nasm over gas?
    Date
    On Sunday 07 September 2003 21:49, Eric W. Biederman wrote:
    > insecure <insecure@mail.od.ua> writes:
    > > On Friday 05 September 2003 15:59, Michael Frank wrote:
    > > > Just got another reply to this thread which helps to explain what I
    > > > meant by "better coders in 98+% of applications"
    > > >
    > > > On Friday 05 September 2003 19:42, Jörn Engel wrote:
    > > > > How big is the .text of the asm and c variant? If the text of yours
    > > > > is much bigger, you just traded 2fish performance for general
    > > > > performance. Everything else will suffer from cache misses. Forget
    > > > > your microbenchmark, your variant will make the machine slower.
    > >
    > > A random example form one small unrelated program (gcc 3.2):
    > >
    > > main:
    > > pushl %ebp
    > > pushl %edi
    > > pushl %esi
    > > pushl %ebx
    > > subl $32, %esp
    > > xorl %ebp, %ebp
    > > cmpl $1, 52(%esp)
    > > movl $0, 20(%esp)
    > > movl $1000000, %edi <----
    > > movl $1000000, 16(%esp) <----
    > > movl $0, 12(%esp)
    > > movl $.LC27, 8(%esp)
    > > je .L274
    > > movl $1, %esi
    > > cmpl 52(%esp), %esi
    > > jge .L272
    > >
    > > No sane human will do that.
    > >
    > >
    > > main:
    > > pushl %ebp
    > > pushl %edi
    > > pushl %esi
    > > pushl %ebx
    > > subl $32, %esp
    > > xorl %ebp, %ebp
    > > cmpl $1, 52(%esp)
    > > movl $0, 20(%esp)
    > > movl $1000000, %edi
    > > movl %edi, 16(%esp) <-- save 4 bytes
    > > movl %ebp, 12(%esp) <-- save 4 bytes
    > > movl $.LC27, 8(%esp)
    > > je .L274
    > > movl $1, %esi
    > > cmpl 52(%esp), %esi
    > > jge .L272
    > >
    > > 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.

    That instruction is in main() initialization sequence. I.e.
    it is executed once per program invocation.
    Summary: we lost 8 bytes for no gain. There's not even a speed gain -
    we lost 8 bytes of _icache_, that will bite us somewhere else.

    > > 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.

    I had an impression people think gcc generates code which
    is 'mostly good' even compared to handwritted code.
    That is not true (yet).
    --
    vda
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:48    [W:0.030 / U:89.024 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site