From: ak@muc.de
To: egcs@cygnus.com
Subject: Poor i386 code from egcs.
Date: Sat, 27 Jun 1998 04:30:00 -0000 [thread overview]
Message-ID: <19980627132952.28632@kali.lrz-muenchen.de> (raw)
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
next reply other threads:[~1998-06-27 4:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-06-27 4:30 ak [this message]
1998-06-27 10:03 ` Joern Rennecke
1998-06-27 12:05 ` ak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19980627132952.28632@kali.lrz-muenchen.de \
--to=ak@muc.de \
--cc=egcs@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).