public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Poor i386 code from egcs.
@ 1998-06-27  4:30 ak
  1998-06-27 10:03 ` Joern Rennecke
  0 siblings, 1 reply; 3+ messages in thread
From: ak @ 1998-06-27  4:30 UTC (permalink / raw)
  To: egcs

Hello,

Given this simple program:
(is it safe to use &tmp after the scope ends? Seems to do no harm in gcc)

#define NUMADDR(x) ({ typeof(x) tmp = (x); &tmp; })

f()
{
	f2(NUMADDR(1));
}

% egcc -v
Reading specs from /pkg/egcs-980605/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.34/specs
gcc version egcs-2.91.34 19980605 (gcc2 ss-980502 experimental)

% egcc -O2 -fomit-frame-pointer -S tcadr.c

Results in this assembler code:

.globl f
        .type    f,@function
f:
        subl $4,%esp
        movl $1,(%esp)
        movl %esp,%eax
        pushl %eax           <----- why can't it push %esp directly?
        call f2
        addl $4,%esp
        addl $4,%esp         <------ why not combine them in one addl?
        ret

Especially the double add looks bad on i386 (it would make sense on m68k,
but not on i386 I think) because it is probably a common occurence. It is
not dependent on the ({ }) block, but happens in an ANSI-C equivalent too.

Is it possible to fix it with a peephole optimizer rule?

I believe the push problem could be fixed by some "widening" of constraints
in i386.md, but my understanding is not good enough to do it myself. 


-Andi

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

end of thread, other threads:[~1998-06-27 12:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-27  4:30 Poor i386 code from egcs ak
1998-06-27 10:03 ` Joern Rennecke
1998-06-27 12:05   ` ak

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