Take the following code:
struct X { float array[4]; };

X a,b;

float foobar () {
  float s = 0;
  X c;
  for (unsigned int d=0; d<4; ++d)
    c.array[d] = a.array[d] * b.array[d];
  for (unsigned int d=0; d<4; ++d)
    s+=c.array[d];
  return s;
}

With -O3 -funroll-loops, we get in .vars:
  c.array[0] = a.array[0] * b.array[0];
  c.array[1] = a.array[1] * b.array[1];
  c.array[2] = a.array[2] * b.array[2];
  ivtmp.34 = &a.array[3];
  ivtmp.38 = &b.array[3];
  ivtmp.40 = &c.array[3];
  D.1572 = *ivtmp.34 * *ivtmp.38;
  *ivtmp.40 = D.1572;
  return D.1572 + c.array[0] + c.array[1] + c.array[2];
Note how we have ivtmp's still there which is wrong.

I am using Daniel Berlin's patch to find these.

-- 
           Summary: invariant/constant not recomputed when ADDR_EXPR changed
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to