While Looking into PR 21485, I noticed this.  This might come up more with the
array references for pointers patch.

Testcase:
typedef long dtype;
typedef dtype longarray[];
int g (longarray *array1, unsigned long i, dtype j)
{
  if ((*array1)[i] < (*array1)[i + 1])
      ++i;
  if (j < (*array1)[i])
    h();
  return i;
}
int g2 (longarray *array1, unsigned long i, dtype j)
{
  dtype a = (*array1)[i];
  dtype b = (*array1)[i + 1];
  dtype c = a;
  if (a < b) ++i, c = b;
  if (j < c)
    h();
  return i;
}

g2 is the optimized version of g.  If I remove the "return i", the RTL level
optimizations catches it.


-- 
           Summary: tree load PRE does not work on array references
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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

Reply via email to