From mboxrd@z Thu Jan 1 00:00:00 1970 From: ak@muc.de To: egcs@cygnus.com Subject: Poor i386 code from egcs. Date: Sat, 27 Jun 1998 04:30:00 -0000 Message-id: <19980627132952.28632@kali.lrz-muenchen.de> X-SW-Source: 1998-06/msg00992.html 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