This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: [tree ssa] DSE extension


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; }

The temporary produced by C++ FE for the result of r.direction() is marked Addressable,
as it's passed by address to r.direction(). After inlining, it doesn't need to live in memory
any more, but the code in tree-ssa-alias.c that is supposed to figure this out can't deal
with the code from y(), which looks like:


this.3<D1528>_11 = (double<D53> *)&<D1502>; <-- nameless <D1502> is the problem; address taken
T.4<D1529>_12 = this.3<D1528>_11 + 8B;
<D1527>_13 = (double<D53> &)T.4<D1529>_12;
# VUSE <<D1502>_21>;
T.8<D1505>_16 = *<D1527>_13; <-- <D15202>.e[1]; doesn't really need to be in memory


So the dead stores survive into RTL. In the example above the RTL optimizers remove them,
but that doesn't work in eon, and that's not how to do it anyway.


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?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]