This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: [tree ssa] DSE extension
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Dale Johannesen <dalej at apple dot com>
- Cc: "gcc at gcc dot gnu dot org list" <gcc at gcc dot gnu dot org>, Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Thu, 1 Apr 2004 14:55:32 -0500
- Subject: Re: RFC: [tree ssa] DSE extension
- References: <3322A010-8412-11D8-8F7D-000A95D7CD40@apple.com>
On Apr 1, 2004, at 14:24, Dale Johannesen wrote:
In C++, it seems that an awful lot of unnecessary stack temp memory
accesses are making it
through the optimizers. For example (reduced from eon in SPEC):
class YY { public:
YY(const YY &v) { e[0] = v.e[0]; e[1] = v.e[1]; e[2] = v.e[2]; }
double &y() { return e[1]; }
double e[3]; };
class XX { public:
YY direction() const { return v; }
YY v; };
int foo(XX& r) {
if (r.direction().y() < 0.000001) return 0;
return 1; }
One possibility is to extend DSE to do better on stack temps, by
temporarily inserting phony
stores in the exit block for all (nonvolatile) automatics (as
suggested in Morgan 10.7.2).
That will at least get rid of the dead stores, although I don't think
it will move the element(s) that
are used out of memory. Am I missing some reason this is a bad idea?
What's a good way to
insert such stores?
What really is needed to SRA with arrays in structs to fix this case
more than what my patch will do.
Also the C++ front-end needs to stop lower constructs like &r->v which
shows up in this testcase.
I have a patch to help out the later which I will submit later today.
Also here is a C example which produces worse code than the C++ example
as the stores are still
there even on the RTL level:
struct YY {
double e[3]; };
static inline double *y(struct YY* this_1) { return &this_1->e[1]; }
struct XX {
struct YY v;
};
static inline struct YY direction (const struct XX* this_1) { return
this_1->v;}
int foo(const struct XX* r) {
struct YY t = direction(r);
if (*y(&t) < 0.000001) return 0;
return 1;
}
Thanks,
Andrew Pinski