From: Joe Buck <jbuck@synopsys.com>
To: Richard Henderson <rth@redhat.com>,
Diego Novillo <dnovillo@redhat.com>,
"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: [tree-ssa] copy propagation and the abstraction penalty
Date: Thu, 15 May 2003 22:48:00 -0000 [thread overview]
Message-ID: <20030515154829.A19150@synopsys.com> (raw)
In-Reply-To: <20030515221748.GC10321@redhat.com>; from rth@redhat.com on Thu, May 15, 2003 at 03:17:48PM -0700
On Thu, May 15, 2003 at 03:17:48PM -0700, Richard Henderson wrote:
> On Thu, May 15, 2003 at 10:10:22AM -0400, Diego Novillo wrote:
> > I'm also wondering if we could change the
> > may-alias between this and UV2150 to a must-alias, which would
> > completely free this program from aliasing problems:
>
> Indeed. And for this case I definitely think it's the right thing to do.
>
> IMO constant propagation should be able to take
>
> T.8_2 = &<UVa150>;
> {
> struct complex * const this;
>
> this_3 = (struct complex * const)T.8_2;
> {
> this->re = 1.0e+0;
>
> and turn it into
>
> (&<UVa150>)->re = 1.0e+0
>
> which folds to
>
> <UVa150>.re = 1.0e+0
>
> At which point we have no aliasing problem, and a subsequent round
> of constant propagation ought to be able to send 1.0e+0 to its
> destination.
That helps this case, but in many other cases the content of the temporary
struct's field will be a variable, and we would still want to copy-propagate.
For example, consider bit vector classes. Typically the [] operator will
be overloaded to return a "bitref" object, which is a struct that has two
fields: a reference to the bit vector, and a bit offset. The compiler
should be able to eliminate the temporary object. We would have
struct bitref;
class bitvec {
public:
void set_bit(unsigned pos, bool value);
bool get_bit(unsigned pos) const;
inline bitref operator[](unsigned pos);
};
struct bitref {
bitref(bitvec& o, unsigned p) : obj(o), pos(p) {}
bitvec& obj;
unsigned pos;
operator bool() const { return obj.get_bit(pos);}
void operator=(bool value) { obj.set_bit(pos, value);}
void operator=(const bitref& src) { obj.set_bit(pos, src);}
};
inline bitref bitvec::operator[](unsigned pos) { return bitref(*this, pos);}
and we want to compile
void assign(bitvec& dest, bitvec& src, unsigned i, unsigned j) {
dest[i] = src[j];
}
Ideally, we should be able to do copy propagation good enough to turn this
into
dest.set_bit(i, src.get_bit(j));
which means that we can kill the two generated bitref objects. Note,
though, that there are no constants. We have {&dest,i} and {&src,j}.
This kind of thing occurs throughout common C++ codes, and really kills us
on the Boost graph library.
next prev parent reply other threads:[~2003-05-15 22:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-14 22:45 Joe Buck
2003-05-15 3:15 ` Andrew Pinski
2003-05-15 14:10 ` Diego Novillo
2003-05-15 17:09 ` Joe Buck
2003-05-15 17:28 ` Joe Buck
2003-05-15 18:01 ` Daniel Berlin
2003-05-15 22:20 ` Richard Henderson
2003-05-15 22:48 ` Joe Buck [this message]
2003-05-15 22:51 ` Joe Buck
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=20030515154829.A19150@synopsys.com \
--to=jbuck@synopsys.com \
--cc=dnovillo@redhat.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).