Consider

struct Data {
  int get() const { return value; }
  int value;
};

struct Object {
  int operator[](int i) const { return data_m->get(); }
  Data *data_m;
};

int foo(Object&o)
{
  return o[0];
}

here we have after forwprop

int foo(Object&) (o)
{
  struct Object * const this;
  struct Data * D.20003;
  int D.20005;
  struct Data * const this;

<bb 2>:
  this_2 = o_1;
  D.20003_4 = this_2->data_m;
  this_5 = D.20003_4;
  D.20005_6 = this_5->value;
  D.20005_7 = D.20005_6;
  D.20005_8 = D.20005_7;
  D.20005_9 = D.20005_8;
  D.20005_10 = D.20005_9;
  return D.20005_10;

}

both memory loads could load from o_1 and D.20003_4 respectively.


-- 
           Summary: Does not propagate memory load base through useless type
                    conversion
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27084

Reply via email to