RFC: [tree ssa] DSE extension

Andrew Pinski pinskia@physics.uc.edu
Thu Apr 1 19:56:00 GMT 2004


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



More information about the Gcc mailing list