public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* suggestion to improve optimization
@ 2000-07-31 14:16 Matthias Klose
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Klose @ 2000-07-31 14:16 UTC (permalink / raw)
  To: gcc; +Cc: 67206

[this suggestions was submitted on the Debian BTS; please CC
 67206@bugs.debian.org on replies.]

Same behaviour in 20000720 CVS.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: suggestion to improve optimization
@ 2001-03-17  0:06 Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2001-03-17  0:06 UTC (permalink / raw)
  To: gcc; +Cc: 67206-forwarded

Here's another example where register pressure causes gcc to overlook some
simple optimisations.  For the attached program, gcc 2.95.2 generates

foo:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %edi
        pushl   %esi
        pushl   %ebx
        movl    n, %eax
        subl    $28, %esp
        movl    %eax, -16(%ebp)
        movl    b, %eax
        movl    8(%ebp), %ebx
        movl    %eax, a
        jmp     .L141
        .p2align 2
.L143:
        movl    $.LC0+1, %edx
        cmpl    %edx, %edx
        movl    -16(%ebp), %edi
        je      .L214

...

.L141:
        movb    (%ebx), %al
        testb   %al, %al
        jne     .L143
        movl    -16(%ebp), %eax
        leal    -12(%ebp), %esp
        popl    %ebx
        popl    %esi
        popl    %edi
        popl    %ebp
        ret

Now n could have been moved to %edi in the first place to eliminate the
second reading from -16(%ebp).  This is what happens when some of the code
at the end of the loop is removed which reduces register pressure.
-- 
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-03-17  0:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-31 14:16 suggestion to improve optimization Matthias Klose
2001-03-17  0:06 Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).