From: dalej@apple.com
To: gcc@gcc.gnu.org
Subject: how to fix anti-optimization?
Date: Wed, 12 Sep 2001 11:34:00 -0000 [thread overview]
Message-ID: <200109121834.LAA21595@scv1.apple.com> (raw)
const double Prescale[] = { 3.0, 5.0 };
extern void bar(double, double);
void foo () { bar(Prescale[0], Prescale[1]); }
With -O1 or higher, gcc substitutes constants 3.0 and 5.0 for the array
references. This isn't a win on targets where the extra copies of these
constants have to go in memory; you get an extra copy of the constants in
data space. Furthermore, on many targets, loading two FP constants
individually requires computing two addresses, while loading them from the
array requires only one address computation. I see that this substitution
would gain if some other optimizations happened to be doable as a result,
e.g. constant folding, but I don't know how to determine that.
The substitution is done in the ARRAY_REF case of expr.c:expand_expr().
It looks like I could hack this by setting TREE_SIDE_EFFECTS on FP
constants, but surely that's not the right way to do it. Any better ideas?
next reply other threads:[~2001-09-12 11:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-12 11:34 dalej [this message]
2001-09-12 15:14 ` Richard Henderson
2001-09-14 12:50 ` Dale Johannesen
2001-09-14 13:02 ` David Edelsohn
2001-09-14 13:36 ` Richard Henderson
2001-09-13 10:50 ` David Edelsohn
2001-09-13 11:03 ` Dale Johannesen
2001-09-14 15:27 Richard Kenner
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=200109121834.LAA21595@scv1.apple.com \
--to=dalej@apple.com \
--cc=gcc@gcc.gnu.org \
/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).