public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Dale Johannesen <dalej@apple.com>
To: Richard Henderson <rth@redhat.com>
Cc: gcc@gcc.gnu.org
Subject: Re: how to fix anti-optimization?
Date: Fri, 14 Sep 2001 12:50:00 -0000	[thread overview]
Message-ID: <200109141950.f8EJoNw06758@scv2.apple.com> (raw)
In-Reply-To: <20010912151445.A13526@redhat.com>

On Wednesday, September 12, 2001, at 03:14 PM, Richard Henderson wrote:

> On Wed, Sep 12, 2001 at 11:35:00AM -0700, dalej@apple.com wrote:
>> 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?
>
> If the constant is not LEGITIMATE_CONSTANT_P, make the ARRAY_REF
> expand as normal, then tag the resulting memory reference with a
> REG_EQUAL note containing the known constant.

Some problems with this.  First, I discover that LEGITIMATE_CONSTANT_P on 
rs6000 accepts some FP consts, after checking to see whether they can be 
*moved* into int regs with 1 instruction per word.  That's not right, is 
it?  It doesn't match the documentation of LEGITIMATE_CONSTANT_P.  I 
suppose the reason is so that here
    double x= 5.0;  double y = 3.172348904532;
the store into x can be done with 2 int stores, while the store into y 
uses lfd/std.  However, that happens regardless of LEGITIMATE_CONSTANT_P, 
by virtue of the 'G' constraint.  OK to change LEGITIMATE_CONSTANT_P to 
reject all FP consts (assuming bootstrap works)?

So after doing that locally I was able to get the suggestion above to work.
   Unfortunately, the effect of the REG_EQUAL note is to cause another copy 
of the constant to be substituted for the array memref later in the 
proceedings; it does make the constant folding work though.

const double Prescale[] = { 3.0, 5.0 };
     bar(Prescale[0], Prescale[1], Prescale[0]*Prescale[1]);

For this, the RT is to load from the array for the 1st two parameters, and 
to do the multiplication at compile time, loading the resulting constant 
15.0 from a new memory loc.  So far I haven't been able to get that.

  reply	other threads:[~2001-09-14 12:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-12 11:34 dalej
2001-09-12 15:14 ` Richard Henderson
2001-09-14 12:50   ` Dale Johannesen [this message]
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=200109141950.f8EJoNw06758@scv2.apple.com \
    --to=dalej@apple.com \
    --cc=gcc@gcc.gnu.org \
    --cc=rth@redhat.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).