This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Poor i386 code from egcs.
- To: egcs at cygnus dot com
- Subject: Poor i386 code from egcs.
- From: ak at muc dot de
- Date: Sat, 27 Jun 1998 13:29:52 +0200
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